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

Use argument parsers to run AI commands #117

Closed
JasonWeill opened this issue Apr 24, 2023 · 0 comments · Fixed by #188
Closed

Use argument parsers to run AI commands #117

JasonWeill opened this issue Apr 24, 2023 · 0 comments · Fixed by #188
Labels
enhancement New feature or request @jupyter-ai/magics

Comments

@JasonWeill
Copy link
Collaborator

JasonWeill commented Apr 24, 2023

Problem

This is a follow-up to the work done on #100. This PR adds an _ai_command function that uses the arguments provided as a space-delimited list. @dlqqq writes:

It would be better to leverage argparse.add_subparser here, but that would require us to rip out the IPython decorators and create the parser object ourselves. [The IPython.core.magic_arguments module]](https://github.com/ipython/ipython/blob/main/IPython/core/magic_arguments.py) does not [have] a decorator for this functionality. In the long-term, it would be more robust to use argparse directly rather than relying on the intermediary layer provided by IPython.

Proposed Solution

Use argparse.add_subparser to parse arguments to %ai commands. As an alternative, consider click; argparse is somewhat notorious for changing its functionality across Python versions, so it may not be ideal for us.

@JasonWeill JasonWeill added the enhancement New feature or request label Apr 24, 2023
@JasonWeill JasonWeill changed the title Use argparse.add_subparser to run AI commands Use argument parsers to run AI commands May 22, 2023
@dlqqq dlqqq mentioned this issue May 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request @jupyter-ai/magics
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant