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

Custom slash command build failed #613

Closed
fbalicchia opened this issue Feb 1, 2024 · 7 comments · Fixed by #637
Closed

Custom slash command build failed #613

fbalicchia opened this issue Feb 1, 2024 · 7 comments · Fixed by #637
Assignees
Labels
bug Something isn't working

Comments

@fbalicchia
Copy link

Hello, I'm working on implementing a custom slash command in ChatUI as per the guidelines provided in the documentation at https://jupyter-ai.readthedocs.io/en/latest/developers/index.html#custom-slash-commands-in-the-chat-ui.

I followed the plugin creation instructions outlined in https://github.com/jupyterlab/jupyter-ai/blob/main/packages/jupyter-ai-module-cookiecutter/README.md.

However, I'm encountering an unusual build issue that I find challenging to comprehend. When I attempt to build the plugin solution using https://github.com/jupyterlab/jupyter-ai/blob/main/scripts/install.sh, the build fails due to a new command plugin issue.

error that I retrieve

@jupyter-ai/jupyter-ai-chat: Traceback (most recent call last):
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_internal/cli/base_command.py", line 180, in exc_logging_wrapper
@jupyter-ai/jupyter-ai-chat:     status = run_func(*args)
@jupyter-ai/jupyter-ai-chat:              ^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_internal/cli/req_command.py", line 245, in wrapper
@jupyter-ai/jupyter-ai-chat:     return func(self, options, args)
@jupyter-ai/jupyter-ai-chat:            ^^^^^^^^^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_internal/commands/install.py", line 377, in run
@jupyter-ai/jupyter-ai-chat:     requirement_set = resolver.resolve(
@jupyter-ai/jupyter-ai-chat:                       ^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 95, in resolve
@jupyter-ai/jupyter-ai-chat:     result = self._result = resolver.resolve(
@jupyter-ai/jupyter-ai-chat:                             ^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 546, in resolve
@jupyter-ai/jupyter-ai-chat:     state = resolution.resolve(requirements, max_rounds=max_rounds)
@jupyter-ai/jupyter-ai-chat:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 427, in resolve
@jupyter-ai/jupyter-ai-chat:     failure_causes = self._attempt_to_pin_criterion(name)
@jupyter-ai/jupyter-ai-chat:                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 239, in _attempt_to_pin_criterion
@jupyter-ai/jupyter-ai-chat:     criteria = self._get_updated_criteria(candidate)
@jupyter-ai/jupyter-ai-chat:                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 230, in _get_updated_criteria
@jupyter-ai/jupyter-ai-chat:     self._add_to_criteria(criteria, requirement, parent=candidate)
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_vendor/resolvelib/resolvers.py", line 148, in _add_to_criteria
@jupyter-ai/jupyter-ai-chat:     matches = self._p.find_matches(
@jupyter-ai/jupyter-ai-chat:               ^^^^^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/provider.py", line 231, in find_matches
@jupyter-ai/jupyter-ai-chat:     return self._factory.find_candidates(
@jupyter-ai/jupyter-ai-chat:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 446, in find_candidates
@jupyter-ai/jupyter-ai-chat:     return self._iter_found_candidates(
@jupyter-ai/jupyter-ai-chat:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 338, in _iter_found_candidates
@jupyter-ai/jupyter-ai-chat:     _get_installed_candidate(),
@jupyter-ai/jupyter-ai-chat:     ^^^^^^^^^^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 284, in _get_installed_candidate
@jupyter-ai/jupyter-ai-chat:     if not specifier.contains(installed_dist.version, prereleases=True):
@jupyter-ai/jupyter-ai-chat:                               ^^^^^^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_internal/metadata/importlib/_dists.py", line 177, in version
@jupyter-ai/jupyter-ai-chat:     return parse_version(self._dist.version)
@jupyter-ai/jupyter-ai-chat:            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/Users/fbalicchia/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_vendor/packaging/version.py", line 49, in parse
@jupyter-ai/jupyter-ai-chat:     return Version(version)
@jupyter-ai/jupyter-ai-chat:            ^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat:   File "/Users/fbalicchia/miniconda3/envs/jupyter-ai/lib/python3.11/site-packages/pip/_vendor/packaging/version.py", line 264, in __init__
@jupyter-ai/jupyter-ai-chat:     match = self._regex.search(version)
@jupyter-ai/jupyter-ai-chat:             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@jupyter-ai/jupyter-ai-chat: TypeError: expected string or bytes-like object, got 'NoneType'
@jupyter-ai/jupyter-ai-chat:

a Custom slash command used to reproduce the problem can be found here [email protected]:fbalicchia/jupyter-ai-chat.git.

Please note that on the other hand, building it with jlpm dev-install in the https://github.com/jupyterlab/jupyter-ai/tree/main/packages/jupyter-ai-chat folder works for me

Could you please advise me on where I might be making a mistake?

Thanks

@fbalicchia fbalicchia added the bug Something isn't working label Feb 1, 2024
@JasonWeill
Copy link
Collaborator

@fbalicchia Thank you for opening this issue! Can you share info about your setup: OS, Python version, etc.? If you see the behavior repeat in other dev environments, sharing that info will help us diagnose this.

@ellisonbg
Copy link
Contributor

I don't believe that the module cookiecutter applies to creating new slash commands. In fact, I think the module cookiecutter should be deleted. @dlqqq thoughts?

@fbalicchia
Copy link
Author

Hello,

My system is an Apple M1 Pro architecture with arm64, and the Python environment was created using the command:

conda create -n jupyter-ai python=3.11

To replicate the issue, please check out the repository at https://github.com/fbalicchia/jupyter-ai-chat and place the plugin inside https://github.com/jupyterlab/jupyter-ai/tree/main/packages.

The jupyter-ai-chat plugin was built using the following commands:

cd packages/jupyter-ai
cookiecutter jupyter-ai-module-cookiecutter

I haven't made any significant changes; I upgraded some libraries and added a small slash command. Please refer to the list of actions I've taken in this comparison:
https://github.com/fbalicchia/jupyter-ai-chat/compare/main..plain-cookiecutter

In the main branch, there is the cookiecutter, while in plain-cookiecutter, there is code built from the scaffold after my changes.

@JasonWeill
Copy link
Collaborator

Thanks for your patience! I am currently looking at another Jupyter AI issue, but I can take a look at this as soon as I can.

@JasonWeill JasonWeill self-assigned this Feb 8, 2024
@JasonWeill
Copy link
Collaborator

@fbalicchia When you have jupyter-ai-chat checked out as a separate package, how did you install it into your local Jupyter AI environment? I checked out your code and I ran pip install -e "." as directed in the README, and I see an AttributeError:

      Traceback (most recent call last):
        File "/opt/miniconda3/envs/jupyter-ai-custom/lib/python3.11/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 167, in prepare_metadata_for_build_editable
          hook = backend.prepare_metadata_for_build_editable
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      AttributeError: module 'hatchling.build' has no attribute 'prepare_metadata_for_build_editable'

@fbalicchia
Copy link
Author

Yes, you're correct !, I've encountered the same issue. In the meantime, I attempted to start from https://github.com/jupyterlab/extension-template using the copier copy command.

After adding dependencies to Jupyter AI, I managed to create my slash command with minimal issues in a separate package.
Inside the Jupyterai package project, I still have problems but I'm not worried at the moment about that

What do you think about replacing cookie-cutter with extension template?

@fbalicchia
Copy link
Author

closed in favor of #636

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants