-
-
Notifications
You must be signed in to change notification settings - Fork 327
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
Migrate to click #188
Merged
Merged
Migrate to click #188
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Please modify the user docs to reflect the breaking change. You might need to modify (and check in changes to) the example workbooks, too. |
JasonWeill
reviewed
May 23, 2023
Co-authored-by: Jason Weill <93281816+JasonWeill@users.noreply.github.com>
I've updated the documentation to reflect this change. 👍 |
JasonWeill
reviewed
May 30, 2023
JasonWeill
approved these changes
May 30, 2023
This was referenced May 31, 2023
dbelgrod
pushed a commit
to dbelgrod/jupyter-ai
that referenced
this pull request
Jun 10, 2024
* migrate to click * prefer "for options" over "for more" in subcommand help Co-authored-by: Jason Weill <93281816+JasonWeill@users.noreply.github.com> * update magics documentation --------- Co-authored-by: Jason Weill <93281816+JasonWeill@users.noreply.github.com>
Marchlak
pushed a commit
to Marchlak/jupyter-ai
that referenced
this pull request
Oct 28, 2024
* migrate to click * prefer "for options" over "for more" in subcommand help Co-authored-by: Jason Weill <93281816+JasonWeill@users.noreply.github.com> * update magics documentation --------- Co-authored-by: Jason Weill <93281816+JasonWeill@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Uses
click
to parse arguments. Notable features:@line_magic_parser.command()
decorator.@click.option()
or@click.argument()
decorators to add new arguments to a subcommand.argparse
, which may include breaking changes version-to-version.Demo
Screen.Recording.2023-05-23.at.4.00.26.PM.mov
Breaking changes
Language models can no longer be invoked by a line magic. The reason for this is that parsers do not handle variadic arguments correctly when using subcommands. Both
argparse
andclick
fail for such a use-case. So for example,%ai list openai
will makeclick
think that you want to execute thelist
model with the promptopenai
, rather than dispatching toopenai
. I really, really tried getting this to work, with one hacky workaround after another. Unfortunately, in the current landscape of CLI parsers in Python, it looks like there's no way of doing this while also parsing subcommands declaratively.However, I believe this is a good breaking change to make. Users rarely have enough horizontal space to fit their entire prompt into a single line, along with the magic command itself and its arguments. This helps keep the first line of each magic short, which also avoids clipping the cell toolbar in JupyterLab. This also makes building the parsers easier, since it allows us to have two separate parsers: one for the cell magic and one for the line magic.