-
Notifications
You must be signed in to change notification settings - Fork 58
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
Command-line interface: jupyter execute #165
Conversation
Thanks @palewire. |
Copy. You would like to aim for something similar in structure to this? https://github.com/jupyter/nbconvert/blob/main/nbconvert/nbconvertapp.py |
Maybe, yes. But it also depends how configurable we want the CLI to be. If we don't want to allow tuning nbclient's parameters, then it's not worth it. But if we do, then we should use traitlets' config. |
I still feel nbconvert and papermill already have CLIs to achieve execution actions so it adds to maintenance burden and makes 3 ways to do things. But I'm not going to get in to way if there's a push and others are willing to support it over time. |
@MSeal, thanks for the feedback. My view is that while nbconvert and papermill are great tools, there's still a gap. nbconvert is framed as a conversion tool, which it's very good at. But the kitchen sink of conversion options is far beyond what anyone who is simply seeking to run a notebook needs. And the conversion focus of its marketing makes its "brand" difficult for newbies to grok. papermill is impressive, but it's overkill for the use case I have in mind, which is a single hacker looking to run a single notebook. Maybe even schedule it with a cron or a GitHub Action. In my mind, that user wants a simple, obvious command to run a notebook. To me, that's something like: jupyter execute my_notebook.ipynb I feel like I can speak for this user, because this user is me. I also see this case crop up among my colleagues, who write a little web scraper or a data processor and want a quick way to schedule runs. And let me add, if we can hammer out a CLI solution everyone is happy with, I am open to developing and supporting it. |
@davidbrochart I've pushed up a new draft that uses JupyterApp and traitlets as the spine of the command, which can now be run like so: jupyter execute binder/empty_notebook.ipynb The file here is still skeletal, of course. Before I try to trick anything out, I'd like to be sure you think it's on the right road. |
It looks great so far! |
Okay, @davidbrochart, another couple steps. I've added command-line options for client inputs. The full suite of args and kwargs seemed like overkill to me, so I cut it down to options that, to me, seemed crucial to terminal users. I welcome your feedback on how I did. Assuming you are onboard with only surfacing a subset, is there a way to allow setting the options for config file users without adding them to the CLI? One key default, in my opinion, is that errors are raised without any additional options needed. In my view, the standard expectation of CLI users is, "If my code has an error, it will be raised." So that's been set here. I've also taken the liberty of adding a new notebook with a single cell,
When you have a moment, take a look and let me know what else you'd like to see here. I'm happy to keep plugging. |
That seems reasonable, and we can support more options in the future if needed.
I'm not sure about that.
👍
Maybe handle the case of
Also, |
Thanks for the feedback, @davidbrochart. I've taken a quick stab at the "no input" message, but we are now running up against ignorance on my side about the internals of traitlets. As far as I can see in the Here's how I did it. Let me know if there's something smarter I can put here. if not notebooks:
self.print_help()
print("jupyter-execute: error: expected path to notebook")
sys.exit(-1) On the second matter, I'm unsure how to properly support the base aliases and flags like |
The usage message I posted above was from entering: jupyter execute nbclient/tests/Error.ipynb --foo Maybe that can help to show a similar message when no notebook is provided. |
Okay. I've done the following:
@davidbrochart, I'm still unable to find an API hook to do that shorter |
Sorry, I can't help you with that. |
Roger, @davidbrochart. I've trimmed that bit to this:
You can test it with:
|
Thanks for all the pointers, @davidbrochart. If there's nothing else on your list, I am going to mark this PR as ready for review. Are there others we should pull into the conversation? |
Hey @palewire - thanks for this PR! It is super helpful to see a specific implementation and some of the discussion it has generated has been helpful for me. I provided some thoughts over in #4 since they are more high level than discussing just this implementation. Would love to hear what folks think |
I've started in on some modifications to the documentation, which appear in the most recent commits. |
Thanks @palewire ! |
Excellent. Mission accomplished on #4. Thanks for all your guidance. |
Thanks for the contribution @palewire 🙂 |
Once we get this released here, I think the next front is to suggest it for inclusion in the |
This pull request has been mentioned on Jupyter Community Forum. There might be relevant details there: https://discourse.jupyter.org/t/jupyter-run-requires-notebook-to-be-previously-run/12250/1 |
I've added here an experimental CLI for the purposes of spurring along the dicussion in #4. It can be tested by doing a quick editable install:
pip install --editable .
Then you can see the options
The notebooks in the binder can be run with it like so: