How do you want your Jupyter Notebook-based tool to behave when a user runs it? You have several choices, which we describe here:
- Tool or dashboard style--only the UI widgets are visible
- Notebook style--all code cells are shown
- Autorun style--shows and runs code cells on load
If you're working out how to develop and deploy the notebook, please refer to the other articles in this series. Continue reading to choose and set the tool display style.
Dashboard ("Tool") style
To deploy a notebook as "tool" or dashboard style, the code will be hidden, but the widgets, plots, and markdown will be displayed.
Two things must be done to deploy your tool in this style. From the Workspace tool's command line, do the following:
First, mark the tool mode on your notebook:
jupyter_tool.py -t notebook-name.ipynb
Then, set your notebook as trusted:
jupyter trust notebook-name.ipynb
Finally, check the code in to subversion (svn).
Note that you cannot make changes to a notebook once it's marked as a trusted tool. If you must make changes to a notebook that's deployed as a Dashboard, first follow the instructions in Notebook style below, then make your changes, and finally re-mark the notebook to use tool mode and trusted mode as above. Then you can check in the Dashboard-style tool's changes to svn!
To deploy a notebook as notebook style, all code in the notebook will be displayed. This is the default for Jupyter notebook based tools, so if it's a new tool, there's nothing special you must do. However, if you're switching a notebook from tool style to notebook style, you must do these things:
First, mark the tool mode to notebook:
jupyter_tool.py -n notebook-name.ipynb
Next, unsign your notebook:
Open your notebook and make a change (if no code change is needed, just add a line of whitespace). Save that.
Lastly, check the source in to subversion (svn) and continue with the tool deploy.
Note that just changing the tool mode or signing/unsigning is insufficient.
You must change the notebook itself then check it in in order to change its behavior.
For autorun, run with -a to autorun all cells on load of the notebook.