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

Fix running the CLI directly from local source #1619

Merged
merged 2 commits into from
May 7, 2024
Merged

Fix running the CLI directly from local source #1619

merged 2 commits into from
May 7, 2024

Conversation

aakrem
Copy link
Collaborator

@aakrem aakrem commented May 6, 2024

Why this PR:
Running the CLI directly from local source is generating the following error:

~/agenta/agenta/agenta-cli main ❯ poetry install
Installing dependencies from lock file

No dependencies to install or update

Installing the current project: agenta (0.14.2)

~/agenta/agenta/agenta-cli main ❯ poetry shell
Spawning shell within .../Library/Caches/pypoetry/virtualenvs/agenta-iJAayExL-py3.12
emulate bash -c '. .../Library/Caches/pypoetry/virtualenvs/agenta-iJAayExL-py3.12/bin/activate'

~/agenta/agenta/agenta-cli main ❯ cd ../examples/baby_name_generator                                                                                               agenta-py3.12

~/agenta/agenta/examples/baby_name_generator main ❯ agenta init                                                                                                    agenta-py3.12
Traceback (most recent call last):
  File ".../Library/Caches/pypoetry/virtualenvs/agenta-iJAayExL-py3.12/bin/agenta", line 6, in <module>
    sys.exit(cli())
             ^^^^^
  File ".../Library/Caches/pypoetry/virtualenvs/agenta-iJAayExL-py3.12/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../Library/Caches/pypoetry/virtualenvs/agenta-iJAayExL-py3.12/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File ".../Library/Caches/pypoetry/virtualenvs/agenta-iJAayExL-py3.12/lib/python3.12/site-packages/click/core.py", line 1685, in invoke
    super().invoke(ctx)
  File ".../Library/Caches/pypoetry/virtualenvs/agenta-iJAayExL-py3.12/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../Library/Caches/pypoetry/virtualenvs/agenta-iJAayExL-py3.12/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../agenta/agenta/agenta-cli/agenta/cli/main.py", line 77, in cli
    notify_update(latest_version)
  File ".../agenta/agenta/agenta-cli/agenta/cli/main.py", line 50, in notify_update
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

Solution:
Adding the setuptools library as dev dependencies is fixing this

@dosubot dosubot bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 6, 2024
Copy link

vercel bot commented May 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
agenta ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 6, 2024 7:06pm

@aakrem aakrem requested a review from aybruhm May 6, 2024 19:02
@dosubot dosubot bot added CLI dependencies Pull requests that update a dependency file labels May 6, 2024
Copy link
Member

@aybruhm aybruhm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and works! Thanks for the PR, @aakrem.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 6, 2024
Copy link
Member

@mmabrouk mmabrouk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks I don't have this issue. Could it be that you ran the first two command in the wrong order (poetry install then poetry shell instead of the other way around):

(base) mahmoudmabrouk@MacBook-Pro-5 agenta-cli % poetry shell
Spawning shell within /Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9
(base) mahmoudmabrouk@MacBook-Pro-5 agenta-cli % emulate bash -c '. /Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/bin/a
ctivate'
(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-5 agenta-cli % poetry install
Configuration file exists at /Users/mahmoudmabrouk/Library/Preferences/pypoetry, reusing this directory.

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

No dependencies to install or update

Installing the current project: agenta (0.14.2)
(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-5 agenta-cli % cd ..
(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-5 agenta-core % cd examples 
(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-5 examples % cd baby_name_generator 
(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-5 baby_name_generator % agenta init
? Please enter the app name                                                                                                                              

Cancelled by user

(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-5 baby_name_generator % ```

@dosubot dosubot bot removed the lgtm This PR has been approved by a maintainer label May 6, 2024
@aybruhm
Copy link
Member

aybruhm commented May 6, 2024

Thanks I don't have this issue. Could it be that you ran the first two command in the wrong order (poetry install then poetry shell instead of the other way around):

(base) mahmoudmabrouk@MacBook-Pro-5 agenta-cli % poetry shell
Spawning shell within /Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9
(base) mahmoudmabrouk@MacBook-Pro-5 agenta-cli % emulate bash -c '. /Users/mahmoudmabrouk/Library/Caches/pypoetry/virtualenvs/agenta-UfaD-TV3-py3.9/bin/a
ctivate'
(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-5 agenta-cli % poetry install
Configuration file exists at /Users/mahmoudmabrouk/Library/Preferences/pypoetry, reusing this directory.

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

No dependencies to install or update

Installing the current project: agenta (0.14.2)
(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-5 agenta-cli % cd ..
(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-5 agenta-core % cd examples 
(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-5 examples % cd baby_name_generator 
(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-5 baby_name_generator % agenta init
? Please enter the app name                                                                                                                              

Cancelled by user

(agenta-py3.9) (base) mahmoudmabrouk@MacBook-Pro-5 baby_name_generator % ```

The first time I ran CLI on development, I encountered the error and installing setuptools solved it for me. Since then, I haven't experienced the it again.

Also, a bit related to this: when you serve an llm example using CLI on development, the variant container will not start due to a missing bson dependency. You'll get: Pymongo ModuleNotFoundError: No module named 'bson'. This gets solved when you add pymongo as a dev dependency in Poetry or include it as part of the llm app example requirements.

@aakrem
Copy link
Collaborator Author

aakrem commented May 6, 2024

maybe. works without it now.

@aakrem aakrem closed this May 6, 2024
@aakrem
Copy link
Collaborator Author

aakrem commented May 7, 2024

actually am still encountring this with new fresh virtual env

~/agenta/agenta/agenta-cli main ❯ poetry shell
Creating virtualenv agenta-5IvcUdw4-py3.12 in .../Library/Caches/pypoetry/virtualenvs
Spawning shell within .../Library/Caches/pypoetry/virtualenvs/agenta-5IvcUdw4-py3.12
emulate bash -c '. .../Library/Caches/pypoetry/virtualenvs/agenta-5IvcUdw4-py3.12/bin/activate'

~/agenta/agenta/agenta-cli main ❯ poetry install                                                                                                                             agenta-py3.12
Installing dependencies from lock file

Package operations: 53 installs, 0 updates, 0 removals

  - Installing six (1.16.0)
  - Installing asttokens (2.4.1)
  - Installing executing (2.0.1)
  - Installing idna (3.6)
  - Installing parso (0.8.3)
  - Installing ptyprocess (0.7.0)
  - Installing pure-eval (0.2.2)
  - Installing sniffio (1.3.0)
  - Installing traitlets (5.14.1)
  - Installing wcwidth (0.2.12)
  - Installing anyio (4.2.0)
  - Installing certifi (2023.11.17)
  - Installing charset-normalizer (3.3.2)
  - Installing decorator (5.1.1)
  - Installing h11 (0.14.0)
  - Installing jedi (0.19.1)
  - Installing matplotlib-inline (0.1.6)
  - Installing pexpect (4.9.0)
  - Installing prompt-toolkit (3.0.43)
  - Installing pygments (2.17.2)
  - Installing stack-data (0.6.3)
  - Installing typing-extensions (4.9.0)
  - Installing urllib3 (2.1.0)
  - Installing attrs (23.2.0): Installing...
  - Installing backoff (2.2.1)
  - Installing dnspython (2.6.1): Installing...
  - Installing backoff (2.2.1)
  - Installing dnspython (2.6.1): Installing...
  - Installing attrs (23.2.0)
  - Installing backoff (2.2.1)
  - Installing dnspython (2.6.1): Installing...
  - Installing dnspython (2.6.1)
  - Installing httpcore (1.0.4)
  - Installing iniconfig (2.0.0)
  - Installing ipython (8.18.1)
  - Installing monotonic (1.6)
  - Installing packaging (23.2)
  - Installing pluggy (1.3.0)
  - Installing py (1.11.0)
  - Installing pydantic (1.10.13)
  - Installing python-dateutil (2.8.2)
  - Installing requests (2.31.0)
  - Installing starlette (0.32.0.post1)
  - Installing toml (0.10.2)
  - Installing websocket-client (1.7.0)
  - Installing zipp (3.17.0)
  - Installing cachetools (5.3.3)
  - Installing click (8.1.7)
  - Installing docker (6.1.3)
  - Installing fastapi (0.108.0)
  - Installing httpx (0.27.0)
  - Installing importlib-metadata (6.11.0)
  - Installing ipdb (0.13.13)
  - Installing posthog (3.1.0)
  - Installing pymongo (4.6.3)
  - Installing pytest (6.2.5)
  - Installing python-dotenv (1.0.0)
  - Installing python-multipart (0.0.6)
  - Installing questionary (1.10.0)

Installing the current project: agenta (0.14.2)
~/agenta/agenta/agenta-cli main ❯ cd ../examples/baby_name_generator                                                                                                         agenta-py3.12

~/agenta/agenta/examples/baby_name_generator main ❯ agenta init                                                                                                              agenta-py3.12
Traceback (most recent call last):
  File ".../Library/Caches/pypoetry/virtualenvs/agenta-5IvcUdw4-py3.12/bin/agenta", line 6, in <module>
    sys.exit(cli())
             ^^^^^
  File ".../Library/Caches/pypoetry/virtualenvs/agenta-5IvcUdw4-py3.12/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../Library/Caches/pypoetry/virtualenvs/agenta-5IvcUdw4-py3.12/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File ".../Library/Caches/pypoetry/virtualenvs/agenta-5IvcUdw4-py3.12/lib/python3.12/site-packages/click/core.py", line 1685, in invoke
    super().invoke(ctx)
  File ".../Library/Caches/pypoetry/virtualenvs/agenta-5IvcUdw4-py3.12/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../Library/Caches/pypoetry/virtualenvs/agenta-5IvcUdw4-py3.12/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../agenta/agenta/agenta-cli/agenta/cli/main.py", line 77, in cli
    notify_update(latest_version)
  File ".../agenta/agenta/agenta-cli/agenta/cli/main.py", line 50, in notify_update
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

@aakrem aakrem reopened this May 7, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label May 7, 2024
@mmabrouk mmabrouk merged commit e369189 into main May 7, 2024
9 checks passed
@mmabrouk mmabrouk deleted the cli-on-dev branch May 7, 2024 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLI dependencies Pull requests that update a dependency file lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants