From d4d160353ed1a9fa8677ed7f1ff93d5fa1c982dc Mon Sep 17 00:00:00 2001 From: Vince Loewe Date: Thu, 29 Feb 2024 12:33:07 -0800 Subject: [PATCH] remove auto install --- litellm/integrations/lunary.py | 18 ++++++++---------- litellm/tests/test_lunary.py | 4 ++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/litellm/integrations/lunary.py b/litellm/integrations/lunary.py index 2a018658ce..51e09a2d80 100644 --- a/litellm/integrations/lunary.py +++ b/litellm/integrations/lunary.py @@ -3,7 +3,8 @@ from datetime import datetime, timezone import traceback import dotenv -import subprocess +import importlib +from pkg_resources import parse_version import sys dotenv.load_dotenv() @@ -56,19 +57,16 @@ class LunaryLogger: def __init__(self): try: import lunary - # lunary.__version__ doesn't exist throws if lunary is not installed - if not hasattr(lunary, "track_event"): + version = importlib.metadata.version("lunary") + # 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 self.lunary_client = lunary except ImportError: - print("Lunary not installed. Installing now...") - subprocess.check_call([sys.executable, "-m", "pip", "install", "lunary", "--upgrade"]) - import importlib - import lunary - importlib.reload(lunary) - - self.lunary_client = lunary + print("Lunary not installed. Please install it using 'pip install lunary'") + raise ImportError def log_event( diff --git a/litellm/tests/test_lunary.py b/litellm/tests/test_lunary.py index e719c5ce38..ab62adee06 100644 --- a/litellm/tests/test_lunary.py +++ b/litellm/tests/test_lunary.py @@ -39,7 +39,7 @@ def test_lunary_template(): except Exception as e: print(e) -test_lunary_template() +# test_lunary_template() def test_lunary_logging_with_metadata(): try: @@ -80,4 +80,4 @@ def test_lunary_logging_with_streaming_and_metadata(): print(e) -#test_lunary_logging_with_streaming_and_metadata() +test_lunary_logging_with_streaming_and_metadata()