Skip to content

Commit

Permalink
Changed the default command to jupyter run, but left in execute a…
Browse files Browse the repository at this point in the history
…s an alias with a deprecation warning (#173)

* Changed the default command to jupyter-run: error: expected path to notebook, but left in  as an alias with a deprecation warning

* Update cli.py

* Update client.rst
  • Loading branch information
palewire authored Nov 12, 2021
1 parent a2b130a commit 635cd62
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
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

0 comments on commit 635cd62

Please sign in to comment.