remove auto install

This commit is contained in:
Vince Loewe 2024-02-29 12:33:07 -08:00
parent e794a9d570
commit d4d160353e
2 changed files with 10 additions and 12 deletions

View file

@ -3,7 +3,8 @@
from datetime import datetime, timezone from datetime import datetime, timezone
import traceback import traceback
import dotenv import dotenv
import subprocess import importlib
from pkg_resources import parse_version
import sys import sys
dotenv.load_dotenv() dotenv.load_dotenv()
@ -56,19 +57,16 @@ class LunaryLogger:
def __init__(self): def __init__(self):
try: try:
import lunary import lunary
# lunary.__version__ doesn't exist throws if lunary is not installed version = importlib.metadata.version("lunary")
if not hasattr(lunary, "track_event"): # if version < 0.1.43 then raise ImportError
if parse_version(version) < parse_version("0.1.43"):
print("Lunary version outdated. Required: > 0.1.43. Upgrade via 'pip install lunary --upgrade'")
raise ImportError raise ImportError
self.lunary_client = lunary self.lunary_client = lunary
except ImportError: except ImportError:
print("Lunary not installed. Installing now...") print("Lunary not installed. Please install it using 'pip install lunary'")
subprocess.check_call([sys.executable, "-m", "pip", "install", "lunary", "--upgrade"]) raise ImportError
import importlib
import lunary
importlib.reload(lunary)
self.lunary_client = lunary
def log_event( def log_event(

View file

@ -39,7 +39,7 @@ def test_lunary_template():
except Exception as e: except Exception as e:
print(e) print(e)
test_lunary_template() # test_lunary_template()
def test_lunary_logging_with_metadata(): def test_lunary_logging_with_metadata():
try: try:
@ -80,4 +80,4 @@ def test_lunary_logging_with_streaming_and_metadata():
print(e) print(e)
#test_lunary_logging_with_streaming_and_metadata() test_lunary_logging_with_streaming_and_metadata()