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

Passing arguments to the notebook #149

Open
achandak123 opened this issue Jun 1, 2021 · 2 comments
Open

Passing arguments to the notebook #149

achandak123 opened this issue Jun 1, 2021 · 2 comments

Comments

@achandak123
Copy link

How can we pass command-line arguments to the notebook? Similar to what papermill does? Papermill uses tags n all for that. What i was thinking of using argv to get the arguments within the notebook, just like we do for regular python scripts. I can achieve this using environment variables as well, however arguments way is way more elegant.

@MSeal
Copy link
Contributor

MSeal commented Jun 1, 2021

In general nbclient is kept less complicated on this capability and exists as a pure manager of kernel object that can be easily extended to more sophisticated use cases (e.g. papermill and testbook). I'd prefer the logic for parameter parsing stay in those wrapping libraries.

That being said one of the differences to python scripts from kernels is that a kernel captures the launch process entirely and it's not always a 1:1 with a process launch like in pure Python, especially for non-ipykernel situations. This means there's not a general way to pass argv into the process that'll consistently work as you'd expect. Kernel's aren't scripts, they're meant to be more of an application that accepts protocol requests to facilitate a living execution environment. Which means these things don't always translate from Python to Notebooks. This is also the reason papermill injects code cells to pass data to a kernel / notebook session, as it works consistently across programming language and kernel infrastructure.

@dokempf
Copy link

dokempf commented Nov 24, 2021

If you are still looking for a lightweight alternative to papermill, I have written a small tool that provides a click-based CLI for notebooks: https://github.com/ssciwr/nbclick It uses nbclient and nbparameterise under the hood.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants