Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Bug Report: Build issue with Module Not Found Error #1067

Closed
1 task done
damianoneill opened this issue May 18, 2024 · 11 comments
Closed
1 task done

🐛 Bug Report: Build issue with Module Not Found Error #1067

damianoneill opened this issue May 18, 2024 · 11 comments

Comments

@damianoneill
Copy link

Which component is this bug for?

Traceloop SDK

📜 Description

Sorry this is more of a question than a Bug Report, didn't see any options for asking a question.

I have an existing, running Langchain (Langserve) application. I have added the following in the python mainline

from traceloop.sdk import Traceloop

Traceloop.init()

And my pyproject.toml file includes the following dependencies

[tool.poetry.dependencies]
python = "^3.11"
uvicorn = "^0.23.2"
langserve = {extras = ["server"], version = ">=0.0.30"}
pydantic = "<2"
openai = "^1.30.1"
langchain-community = "^0.0.38"
distro = "^1.9.0"
python-dotenv = "^1.0.1"
traceloop-sdk = "^0.18.0"

I am using the following python version

 poetry env info
Configuration file exists at /Users/doneill/Library/Preferences/pypoetry, reusing this directory.

Consider moving TOML configuration files to /Users/doneill/Library/Application Support/pypoetry, as support for the legacy directory will be removed in an upcoming release.

Virtualenv
Python:         3.11.6
Implementation: CPython
Path:           /Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv
Executable:     /Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/bin/python
Valid:          True

System
Platform:   darwin
OS:         posix
Python:     3.11.6
Path:       /Users/doneill/.asdf/installs/python/3.11.6
Executable: /Users/doneill/.asdf/installs/python/3.11.6/bin/python3.11
(chat-py3.11) ➜  chat git:(main) ✗

When I run this, I get the following error.

  File "/Users/doneill/.asdf/installs/python/3.11.6/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/app/server.py", line 16, in <module>
    from traceloop.sdk import Traceloop
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/traceloop/sdk/__init__.py", line 8, in <module>
    from opentelemetry.sdk.trace import SpanProcessor
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/opentelemetry/sdk/trace/__init__.py", line 44, in <module>
    from opentelemetry import context as context_api
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/opentelemetry/context/__init__.py", line 25, in <module>
    from opentelemetry.util._importlib_metadata import entry_points
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/opentelemetry/util/_importlib_metadata.py", line 17, in <module>
    from importlib_metadata import (  # type: ignore
ModuleNotFoundError: No module named 'importlib_metadata'

Apologies if this is a newbie question, I was expecting that all the required dependencies would be pulled, can you confirm if I am supposed to import all the missing modules? Or is there something that I have done wrong.

I have looked at a few other pyproject.toml files and do not see them bringing in a list of 3rd parties.

Thanks in advance,
Damian.

👟 Reproduction steps

N/A - build question

👍 Expected behavior

It should startup with error.

👎 Actual Behavior with Screenshots

  File "/Users/doneill/.asdf/installs/python/3.11.6/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/app/server.py", line 16, in <module>
    from traceloop.sdk import Traceloop
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/traceloop/sdk/__init__.py", line 8, in <module>
    from opentelemetry.sdk.trace import SpanProcessor
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/opentelemetry/sdk/trace/__init__.py", line 44, in <module>
    from opentelemetry import context as context_api
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/opentelemetry/context/__init__.py", line 25, in <module>
    from opentelemetry.util._importlib_metadata import entry_points
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/opentelemetry/util/_importlib_metadata.py", line 17, in <module>
    from importlib_metadata import (  # type: ignore
ModuleNotFoundError: No module named 'importlib_metadata'

🤖 Python Version

3.11.6 on OSX

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find similar issue

Are you willing to submit PR?

None

@damianoneill
Copy link
Author

If I add this module, it then leads to the next missing dep, see below.

  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/uvicorn/server.py", line 68, in serve
    config.load()
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/uvicorn/config.py", line 467, in load
    self.loaded_app = import_from_string(self.app)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/uvicorn/importer.py", line 24, in import_from_string
    raise exc from None
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/uvicorn/importer.py", line 21, in import_from_string
    module = importlib.import_module(module_str)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/doneill/.asdf/installs/python/3.11.6/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/app/server.py", line 16, in <module>
    from traceloop.sdk import Traceloop
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/traceloop/sdk/__init__.py", line 15, in <module>
    from traceloop.sdk.metrics.metrics import MetricsWrapper
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/traceloop/sdk/metrics/metrics.py", line 6, in <module>
    from opentelemetry.exporter.otlp.proto.grpc.metric_exporter import (
  File "/Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/lib/python3.11/site-packages/opentelemetry/exporter/otlp/proto/grpc/metric_exporter/__init__.py", line 19, in <module>
    from grpc import ChannelCredentials, Compression
ModuleNotFoundError: No module named 'grpc'

@nirga
Copy link
Member

nirga commented May 18, 2024

Hey @damianoneill this is weird, these should be installed with OpenTelemetry. Can you verify that poetry install was ran with no errors?

@damianoneill
Copy link
Author

Thanks @nirga for the quick response. See below, where I wiped the virtual environment and reinstalled from scratch.

(chat-py3.11) ➜  chat git:(main) ✗ rm -rf .venv
(chat-py3.11) ➜  chat git:(main) ✗ exit
➜  chat git:(main) ✗ poetry shell
Configuration file exists at /Users/doneill/Library/Preferences/pypoetry, reusing this directory.

Consider moving TOML configuration files to /Users/doneill/Library/Application Support/pypoetry, as support for the legacy directory will be removed in an upcoming release.
Creating virtualenv chat in /Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv
Spawning shell within /Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv
Configuration file exists at /Users/doneill/Library/Preferences/pypoetry, reusing this directory.

Consider moving TOML configuration files to /Users/doneill/Library/Application Support/pypoetry, as support for the legacy directory will be removed in an upcoming release.
➜  chat emulate bash -c '. /Users/doneill/projects/ssd-git.juniper.net/aide-jcloud/jllm/chat/.venv/bin/activate'
(chat-py3.11) ➜  chat git:(main) ✗ poetry install
Configuration file exists at /Users/doneill/Library/Preferences/pypoetry, reusing this directory.

Consider moving TOML configuration files to /Users/doneill/Library/Application Support/pypoetry, as support for the legacy directory will be removed in an upcoming release.
Installing dependencies from lock file

Package operations: 95 installs, 0 updates, 0 removals

  • Installing idna (3.7)
  • Installing sniffio (1.3.1)
  • Installing anyio (4.3.0)
  • Installing certifi (2024.2.2)
  • Installing charset-normalizer (3.3.2)
  • Installing typing-extensions (4.11.0)
  • Installing urllib3 (2.2.1)
  • Installing click (8.1.7)
  • Installing h11 (0.14.0)
  • Installing jsonpointer (2.4)
  • Installing mdurl (0.1.2)
  • Installing orjson (3.10.3)
  • Installing pydantic (1.10.15)
  • Installing requests (2.31.0)
  • Installing starlette (0.37.2)
  • Installing fastapi (0.110.3)
  • Installing frozenlist (1.4.1)
  • Installing httpcore (1.0.5)
  • Installing jsonpatch (1.33)
  • Installing langsmith (0.1.59)
  • Installing markdown-it-py (3.0.0)
  • Installing multidict (6.0.5)
  • Installing mypy-extensions (1.0.0)
  • Installing packaging (23.2)
  • Installing pygments (2.18.0)
  • Installing pyyaml (6.0.1)
  • Installing regex (2024.5.15)
  • Installing six (1.16.0)
  • Installing smmap (5.0.1)
  • Installing tenacity (8.3.0)
  • Installing uvicorn (0.23.2)
  • Installing aiosignal (1.3.1)
  • Installing anthropic (0.26.0)
  • Installing attrs (23.2.0)
  • Installing backoff (2.2.1)
  • Installing colorama (0.4.6)
  • Installing gitdb (4.0.11)
  • Installing httpx (0.27.0)
  • Installing inflection (0.5.1)
  • Installing langchain-core (0.1.52)
  • Installing markupsafe (2.1.5)
  • Installing marshmallow (3.21.2)
  • Installing monotonic (1.6)
  • Installing opentelemetry-api (1.24.0)
  • Installing opentelemetry-instrumentation (0.45b0)
  • Installing opentelemetry-semantic-conventions (0.45b0)
  • Installing opentelemetry-semantic-conventions-ai (0.2.0)
  • Installing python-dateutil (2.9.0.post0)
  • Installing rich (13.7.1)
  • Installing shellingham (1.5.4)
  • Installing sse-starlette (1.8.2)
  • Installing tiktoken (0.7.0)
  • Installing typing-inspect (0.9.0)
  • Installing wrapt (1.16.0)
  • Installing yarl (1.9.4)
  • Installing aiohttp (3.9.5)
  • Installing dataclasses-json (0.6.6)
  • Installing deprecated (1.2.14)
  • Installing gitpython (3.1.43)
  • Installing jinja2 (3.1.4)
  • Installing langserve (0.1.1)
  • Installing libcst (1.3.1)
  • Installing numpy (1.26.4)
  • Installing opentelemetry-exporter-otlp-proto-grpc (1.24.0)
  • Installing opentelemetry-exporter-otlp-proto-http (1.24.0)
  • Installing opentelemetry-instrumentation-anthropic (0.18.0)
  • Installing opentelemetry-instrumentation-bedrock (0.18.0)
  • Installing opentelemetry-instrumentation-chromadb (0.18.0)
  • Installing opentelemetry-instrumentation-cohere (0.18.0)
  • Installing opentelemetry-instrumentation-haystack (0.18.0)
  • Installing opentelemetry-instrumentation-langchain (0.18.0)
  • Installing opentelemetry-instrumentation-llamaindex (0.18.0)
  • Installing opentelemetry-instrumentation-openai (0.18.0)
  • Installing opentelemetry-instrumentation-pinecone (0.18.0)
  • Installing opentelemetry-instrumentation-qdrant (0.18.0)
  • Installing opentelemetry-instrumentation-replicate (0.18.0)
  • Installing opentelemetry-instrumentation-requests (0.45b0)
  • Installing opentelemetry-instrumentation-sqlalchemy (0.45b0)
  • Installing opentelemetry-instrumentation-transformers (0.18.0)
  • Installing opentelemetry-instrumentation-urllib3 (0.45b0)
  • Installing opentelemetry-instrumentation-vertexai (0.18.0)
  • Installing opentelemetry-instrumentation-watsonx (0.18.0)
  • Installing opentelemetry-instrumentation-weaviate (0.18.0)
  • Installing opentelemetry-sdk (1.24.0)
  • Installing posthog (3.5.0)
  • Installing sentry-sdk (2.2.0)
  • Installing sqlalchemy (2.0.30)
  • Installing tomlkit (0.12.5)
  • Installing typer (0.9.4)
  • Installing distro (1.9.0)
  • Installing langchain-cli (0.0.22)
  • Installing langchain-community (0.0.38)
  • Installing openai (1.30.1)
  • Installing python-dotenv (1.0.1)
  • Installing traceloop-sdk (0.18.0)

Installing the current project: chat (0.1.0)
(chat-py3.11) ➜  chat git:(main) ✗

@damianoneill
Copy link
Author

And the pip list

(chat-py3.11) ➜  chat git:(main) ✗ pip list
Package                                    Version     Editable project location
------------------------------------------ ----------- -----------------------------------------------------------------
aiohttp                                    3.9.5
aiosignal                                  1.3.1
anthropic                                  0.26.0
anyio                                      4.3.0
attrs                                      23.2.0
backoff                                    2.2.1
certifi                                    2024.2.2
charset-normalizer                         3.3.2
chat                                       0.1.0     
click                                      8.1.7
colorama                                   0.4.6
dataclasses-json                           0.6.6
Deprecated                                 1.2.14
distro                                     1.9.0
fastapi                                    0.110.3
frozenlist                                 1.4.1
gitdb                                      4.0.11
GitPython                                  3.1.43
h11                                        0.14.0
httpcore                                   1.0.5
httpx                                      0.27.0
idna                                       3.7
inflection                                 0.5.1
Jinja2                                     3.1.4
jsonpatch                                  1.33
jsonpointer                                2.4
langchain-cli                              0.0.22
langchain-community                        0.0.38
langchain-core                             0.1.52
langserve                                  0.1.1
langsmith                                  0.1.59
libcst                                     1.3.1
markdown-it-py                             3.0.0
MarkupSafe                                 2.1.5
marshmallow                                3.21.2
mdurl                                      0.1.2
monotonic                                  1.6
multidict                                  6.0.5
mypy-extensions                            1.0.0
numpy                                      1.26.4
openai                                     1.30.1
opentelemetry-api                          1.24.0
opentelemetry-exporter-otlp-proto-grpc     1.24.0
opentelemetry-exporter-otlp-proto-http     1.24.0
opentelemetry-instrumentation              0.45b0
opentelemetry-instrumentation-anthropic    0.18.0
opentelemetry-instrumentation-bedrock      0.18.0
opentelemetry-instrumentation-chromadb     0.18.0
opentelemetry-instrumentation-cohere       0.18.0
opentelemetry-instrumentation-haystack     0.18.0
opentelemetry-instrumentation-langchain    0.18.0
opentelemetry-instrumentation-llamaindex   0.18.0
opentelemetry-instrumentation-openai       0.18.0
opentelemetry-instrumentation-pinecone     0.18.0
opentelemetry-instrumentation-qdrant       0.18.0
opentelemetry-instrumentation-replicate    0.18.0
opentelemetry-instrumentation-requests     0.45b0
opentelemetry-instrumentation-sqlalchemy   0.45b0
opentelemetry-instrumentation-transformers 0.18.0
opentelemetry-instrumentation-urllib3      0.45b0
opentelemetry-instrumentation-vertexai     0.18.0
opentelemetry-instrumentation-watsonx      0.18.0
opentelemetry-instrumentation-weaviate     0.18.0
opentelemetry-sdk                          1.24.0
opentelemetry-semantic-conventions         0.45b0
opentelemetry-semantic-conventions-ai      0.2.0
orjson                                     3.10.3
packaging                                  23.2
pip                                        23.3.2
posthog                                    3.5.0
pydantic                                   1.10.15
Pygments                                   2.18.0
python-dateutil                            2.9.0.post0
python-dotenv                              1.0.1
PyYAML                                     6.0.1
regex                                      2024.5.15
requests                                   2.31.0
rich                                       13.7.1
sentry-sdk                                 2.2.0
setuptools                                 69.0.3
shellingham                                1.5.4
six                                        1.16.0
smmap                                      5.0.1
sniffio                                    1.3.1
SQLAlchemy                                 2.0.30
sse-starlette                              1.8.2
starlette                                  0.37.2
tenacity                                   8.3.0
tiktoken                                   0.7.0
tomlkit                                    0.12.5
traceloop-sdk                              0.18.0
typer                                      0.9.4
typing_extensions                          4.11.0
typing-inspect                             0.9.0
urllib3                                    2.2.1
uvicorn                                    0.23.2
wrapt                                      1.16.0
yarl                                       1.9.4

[notice] A new release of pip is available: 23.3.2 -> 24.0
[notice] To update, run: pip install --upgrade pip
(chat-py3.11) ➜  chat git:(main) ✗

@nirga
Copy link
Member

nirga commented May 18, 2024

@damianoneill Everything looks right, and we have users that use OpenLLMetry with langserve. Can you compare your code to this example with langserve? #1043

Also, welcome to join our community slack might be easier to communicate - https://traceloop.com/slack

@damianoneill
Copy link
Author

@nirga thanks for your patience, I'm not a python developer 😄 and for the pointer to the PR.

You are referencing the source, rather than including it in the dep section (and pulling from pypi) as I have done.

[tool.poetry.dependencies.traceloop-sdk]
path = "../traceloop-sdk"
develop = true

So I checked out your PR, updated the dep to pull it in and started the langchain serve command, no complaints about missing modules, it bombs out with a missing TRACELOOP_API_KEY, as expected.

So I then used poetry show --tree to see where the deps are being installed from, it looks like there coming from your use of chromadb. For example:

chromadb 0.5.0 Chroma.
├── bcrypt >=4.0.1
├── build >=1.0.3
│   ├── colorama *
│   ├── packaging >=19.1
│   └── pyproject-hooks *
├── chroma-hnswlib 0.7.3
│   └── numpy *
├── fastapi >=0.95.2
│   ├── pydantic >=1.7.4,<1.8 || >1.8,<1.8.1 || >1.8.1,<2.0.0 || >2.0.0,<2.0.1 || >2.0.1,<2.1.0 || >2.1.0,<3.0.0
│   │   └── typing-extensions >=4.2.0
│   ├── starlette >=0.37.2,<0.38.0
│   │   └── anyio >=3.4.0,<5
│   │       ├── idna >=2.8
│   │       └── sniffio >=1.1
│   └── typing-extensions >=4.8.0 (circular dependency aborted here)
├── grpcio >=1.58.0
├── importlib-resources *

...

Note the import of importlib-resources and further imports of all the opentelemetry packages come later, e.g. opentelemetry-exporter-otlp-proto-grpc >=1.2.0

Please correct me if I'm wrong, but it seems that the libraries need to be manually imported. That including traceloop-sdk wont be enough?

Damian.

@nirga
Copy link
Member

nirga commented May 19, 2024

Hmm I'll try to reproduce it locally. It should work without requiring any extra dependencies and I'm not aware of anyone else needing this 🤔

@damianoneill
Copy link
Author

@nirga dont worry, I'll progress myself, you've given me enough to start working through and excluding stuff until I find the issue. Appreciate your help with this.

@damianoneill
Copy link
Author

@nirga apologies, I've found the issue, it has nothing to do with your environment. I'm behind a corporate firewall, if I build on my home computer, there are no issues, so looks like somehow the opentelemetry modules are not getting pulled on our VPN.

Thankyou for your help, sorry for being a distraction.
Damian.

@damianoneill
Copy link
Author

Closing issue.

@nirga
Copy link
Member

nirga commented May 19, 2024

@damianoneill thanks for verifying! 🙏🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants