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

Changed the default command to jupyter run, but left in execute as an alias with a deprecation warning #173

Merged
merged 3 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,23 +173,23 @@ Using a command-line interface

This section will illustrate how to run notebooks from your terminal. It supports the most basic use case. For more sophisticated execution options, consider the `papermill <https://pypi.org/project/papermill/>`_ library.

This library's command line tool is available by running `jupyter execute`. It expects notebooks as input arguments and accepts optional flags to modify the default behavior.
This library's command line tool is available by running `jupyter run`. It expects notebooks as input arguments and accepts optional flags to modify the default behavior.

Running a notebook is this easy.::

jupyter execute notebook.ipynb
jupyter run notebook.ipynb

You can pass more than one notebook as well.::

jupyter execute notebook.ipynb notebook2.ipynb
jupyter run notebook.ipynb notebook2.ipynb

By default, notebook errors will be raised and printed into the terminal. You can suppress them by passing the ``--allow-errors`` flag.::

jupyter execute notebook.ipynb --allow-errors
jupyter run notebook.ipynb --allow-errors

Other options allow you to modify the timeout length and dictate the kernel in use. A full set of options is available via the help command.::

jupyter execute --help
jupyter run --help

An application used to execute notebook files (*.ipynb)

Expand Down
19 changes: 16 additions & 3 deletions nbclient/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class NbClientApp(JupyterApp):
"""

version = __version__
name = 'jupyter-execute'
name = 'jupyter-run'
aliases = nbclient_aliases
flags = nbclient_flags

Expand Down Expand Up @@ -106,7 +106,7 @@ def initialize(self, argv=None):

# If there are none, throw an error
if not self.notebooks:
print("jupyter-execute: error: expected path to notebook")
print(f"{self.name}: error: expected path to notebook")
sys.exit(-1)

# Loop and run them one by one
Expand Down Expand Up @@ -154,4 +154,17 @@ def run_notebook(self, notebook_path):
client.execute()


main = NbClientApp.launch_instance
class NbClientAlias(NbClientApp):
"""
An alias to the run command.
"""
name = 'jupyter-execute'

@catch_config_error
def initialize(self, argv=None):
print("This alias to `jupyter run` may be deprecated in the future. Please switch to using `run`.")
super().initialize(argv)


run = NbClientApp.launch_instance
execute = NbClientAlias.launch_instance
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def read_reqs(fname):
extras_require=extras_require,
entry_points={
'console_scripts': [
'jupyter-execute = nbclient.cli:main',
'jupyter-run = nbclient.cli:run',
'jupyter-execute = nbclient.cli:execute',
],
},
project_urls={
Expand Down