comet-ml / comet-llm

Log, Track, and Visualize your LLM Prompts and Chains
MIT License
491 stars 28 forks source link

Run comet_llm in Kaggle, encounter urllib3 conflict #100

Closed yennhi95zz closed 1 week ago

yennhi95zz commented 7 months ago

Please refer the error below:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
File /opt/conda/lib/python3.10/site-packages/requests_toolbelt/_compat.py:48
     47 try:
---> 48     from requests.packages.urllib3.contrib import appengine as gaecontrib
     49 except ImportError:

ImportError: cannot import name 'appengine' from 'requests.packages.urllib3.contrib' (/opt/conda/lib/python3.10/site-packages/urllib3/contrib/__init__.py)

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
Cell In[2], line 3
      1 import os
      2 from openai import OpenAI
----> 3 import comet_llm
      4 from IPython.display import display
      5 import ipywidgets as widgets

File /opt/conda/lib/python3.10/site-packages/comet_llm/__init__.py:15
      1 # -*- coding: utf-8 -*-
      2 # *******************************************************
      3 #   ____                     _               _
   (...)
     12 #  LICENSE file in the root directory of this package.
     13 # *******************************************************
---> 15 from . import app, autologgers, config, logging
     16 from .config import init, is_ready
     18 if config.comet_disabled():

File /opt/conda/lib/python3.10/site-packages/comet_llm/autologgers/__init__.py:15
      1 # -*- coding: utf-8 -*-
      2 # *******************************************************
      3 #   ____                     _               _
   (...)
     12 #  LICENSE file in the root directory of this package.
     13 # *******************************************************
---> 15 from .api import patch

File /opt/conda/lib/python3.10/site-packages/comet_llm/autologgers/api.py:15
      1 # -*- coding: utf-8 -*-
      2 # *******************************************************
      3 #   ____                     _               _
   (...)
     12 #  LICENSE file in the root directory of this package.
     13 # *******************************************************
---> 15 import comet_llm.config
     17 from ..import_hooks import finder, registry
     18 from .openai import patcher as openai_patcher

File /opt/conda/lib/python3.10/site-packages/comet_llm/config.py:33
     29         pass
     30         logging.disable(0)
---> 33 comet_ml, comet_ml_config = _muted_import_comet_ml()
     36 def _extend_comet_ml_config() -> None:
     37     CONFIG_MAP_EXTENSION = {
     38         "comet.disable": {"type": int, "default": 0},
     39         "comet.logging.console": {"type": str, "default": "INFO"},
     40         "comet.raise_exceptions_on_error": {"type": int, "default": 0},
     41     }

File /opt/conda/lib/python3.10/site-packages/comet_llm/config.py:24, in _muted_import_comet_ml()
     22 try:
     23     logging.disable(logging.CRITICAL)
---> 24     import comet_ml
     25     import comet_ml.config
     27     return comet_ml, comet_ml.config  # type: ignore

File /opt/conda/lib/python3.10/site-packages/comet_ml/__init__.py:25
     22 import traceback
     24 from ._logging import _setup_comet_http_handler, _setup_comet_logging
---> 25 from ._online import ExistingExperiment, Experiment
     26 from ._reporting import (
     27     EXPERIMENT_CREATED,
     28     EXPERIMENT_CREATION_DURATION,
     29     EXPERIMENT_CREATION_FAILED,
     30 )
     31 from ._typing import Any, Dict, Optional, Tuple

File /opt/conda/lib/python3.10/site-packages/comet_ml/_online.py:24
     21 import sentry_sdk
     23 from . import announcements, reporter
---> 24 from ._error_tracking import _setup_sentry_error_tracker
     25 from ._logging import _setup_comet_http_handler
     26 from ._reporting import (
     27     EXPERIMENT_CREATED,
     28     EXPERIMENT_CREATION_DURATION,
     29     EXPERIMENT_CREATION_FAILED,
     30 )

File /opt/conda/lib/python3.10/site-packages/comet_ml/_error_tracking.py:21
     19 from ._logging import _setup_sentry_error_handlers
     20 from ._typing import Any, Dict, Optional
---> 21 from .env_logging import _get_non_pii_env_details
     24 def _setup_sentry_error_tracker(
     25     sentry_dsn, experiment_id, comet_url, debug, feature_toggles
     26 ):
     27     # type: (str, str, str, bool, Optional[Dict[str, bool]]) -> Any
     28     sentry_client = sentry_sdk.init(
     29         sentry_dsn,
     30         integrations=[],
     31         default_integrations=False,
     32         debug=debug,
     33     )

File /opt/conda/lib/python3.10/site-packages/comet_ml/env_logging.py:38
     35 from six.moves.urllib.parse import urlparse
     37 from ._typing import Any, Dict, List, Optional, Tuple
---> 38 from .connection import get_backend_address
     39 from .logging_messages import (
     40     LOG_CONDA_ENV_ERROR,
     41     LOG_CONDA_ENV_RETURN_CODE,
   (...)
     45     LOG_CONDA_PACKAGES_RETURN_CODE,
     46 )
     47 from .messages import SystemDetailsMessage

File /opt/conda/lib/python3.10/site-packages/comet_ml/connection.py:51
     49 from requests import HTTPError, RequestException, Response, Session
     50 from requests.adapters import HTTPAdapter
---> 51 from requests_toolbelt import MultipartEncoder, MultipartEncoderMonitor
     52 from requests_toolbelt.adapters.socket_options import TCPKeepAliveAdapter
     53 from urllib3.util.retry import Retry

File /opt/conda/lib/python3.10/site-packages/requests_toolbelt/__init__.py:12
      1 # -*- coding: utf-8 -*-
      2 """
      3 requests-toolbelt
      4 =================
   (...)
      9 :license: Apache v2.0, see LICENSE for more details
     10 """
---> 12 from .adapters import SSLAdapter, SourceAddressAdapter
     13 from .auth.guess import GuessAuth
     14 from .multipart import (
     15     MultipartEncoder, MultipartEncoderMonitor, MultipartDecoder,
     16     ImproperBodyPartContentException, NonMultipartContentTypeException
     17     )

File /opt/conda/lib/python3.10/site-packages/requests_toolbelt/adapters/__init__.py:12
      1 # -*- coding: utf-8 -*-
      2 """
      3 requests-toolbelt.adapters
      4 ==========================
   (...)
      9 :license: Apache v2.0, see LICENSE for more details
     10 """
---> 12 from .ssl import SSLAdapter
     13 from .source import SourceAddressAdapter
     15 __all__ = ['SSLAdapter', 'SourceAddressAdapter']

File /opt/conda/lib/python3.10/site-packages/requests_toolbelt/adapters/ssl.py:16
     12 import requests
     14 from requests.adapters import HTTPAdapter
---> 16 from .._compat import poolmanager
     19 class SSLAdapter(HTTPAdapter):
     20     """
     21     A HTTPS Adapter for Python Requests that allows the choice of the SSL/TLS
     22     version negotiated by Requests. This can be used either to enforce the
   (...)
     43     properly when used with proxies.
     44     """

File /opt/conda/lib/python3.10/site-packages/requests_toolbelt/_compat.py:50
     48         from requests.packages.urllib3.contrib import appengine as gaecontrib
     49     except ImportError:
---> 50         from urllib3.contrib import appengine as gaecontrib
     52 PY3 = sys.version_info > (3, 0)
     54 if PY3:

ImportError: cannot import name 'appengine' from 'urllib3.contrib' (/opt/conda/lib/python3.10/site-packages/urllib3/contrib/__init__.py)

![Uploading Screen Shot 2023-11-26 at 22.02.11.png…]()

Lothiraldan commented 7 months ago

Hi @yennhi95zz, we were able to reproduce your issue inside a Kaggle notebook. It seems that a package triggers the update of Urllib3 to version 2.1.0 but not all of the other dependencies that are related to Urllib3, resulting in a broken environment. We were not available to pinpoint which Python package was triggering the update at this time. Given that Urllib3 version 2 is a major update and that Kaggle Notebook have a lot of packaged pre-installed, we recommend for you to install comet_llm the following way for the time being: %pip install comet_llm "urllib3<2". This will ensure that you don't ends up with a broken environment. Could you give it a try and let us know if that works for you?

dsblank commented 1 week ago

Closing this issue as stale. Please re-open if you have additional comments. Thanks!