Executing One Notebook From Another - Passing Through Processed Markdown

34 views
Skip to first unread message

adam....@tribalgroup.com

unread,
Oct 10, 2016, 8:37:42 AM10/10/16
to Project Jupyter
I would like to be able to maintain a series of notebooks as reusable templates and to execute these for a set of run-time parameters, keeping the results for each. The point is to be able to avoid forking the code; the effect I am looking for would be equivalent to having multiple copies of the same notebook differing only by a cell containing a handful of variable initialisations. The reusable code is subject to change and extension, and I would still like to be able to explore the state after executing the "reusable" notebook, by adding cells into the notebook which executes it.

I currently use the %run magic, passing it a *.ipynb file. This works insomuch as the stdout and stderr and inline plots come through into the calling notebook.
The limitation of this is that I loose any headings and notes and have to resort to extensive print "...." to create headings. This makes the output much less presentable to stakeholders.

As far as I can tell, nbconvert does not allow me to pass in variables. It could be used to automate the process by writing a file of runtime parameters to a consistent location before nb-converting the "reusable" and saving, but this feels rather inelegant.

Anyone got any good ideas??

Cheers, Adam

Antonino Ingargiola

unread,
Oct 11, 2016, 10:26:23 PM10/11/16
to Project Jupyter
Hi Adam,

to run notebook passing parameters you can use nbrun:


The parameters are inserted as the second cell (so that the first can have default values).

Antonio

adam....@tribalgroup.com

unread,
Oct 12, 2016, 5:59:11 AM10/12/16
to Project Jupyter
Antonino -
That is a good solution to the problem. My immediate need is to execute only a single run, but I will also find value in iterating over parameter values as you describe.

You give a good description of the problem nbrun is intended to solve on github.

Thanks for sharing.

Adam
Reply all
Reply to author
Forward
0 new messages