Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run a Jupyter notebook from another notebook while changing the outputs of the notebook running

I would like to run a Jupyter notebook from another one changing the outputs inside the notebook running instead of having the outputs printing in the notebook commanding the run.
I know that there is the %run notebook.ipynb command but it displays the outputs inside the notebook with this line and does not change the outputs in the notebook run.

like image 218
Valentin Richer Avatar asked Nov 15 '25 13:11

Valentin Richer


2 Answers

You can use papermill a package that will allow you to run parameterized notebooks from the CLI or python code

import papermill as pm

pm.execute_notebook(
   'path/to/input.ipynb',
   'path/to/output.ipynb',
   parameters=dict(alpha=0.6, ratio=0.1)
)

like image 191
Luis Blanche Avatar answered Nov 18 '25 04:11

Luis Blanche


Not possible the way you ask.

TL;DR

Starting jupyter notebook programmatically from another notebook talk about opening other notebook via command in another tab of browser, but it is not run automatically on open.

If notebook is already opened IMHO your request is not possible to fulfill in way your asked. With %run the target notebook is running inside your commanding notebook, parameter to %run is a file. Notebook loaded in other tab of your browser is just some data loaded to browser (actually more complex than that). Suppose you have several tabs with same notebook file open in browser - how you want to choose which one to run?

like image 32
Alexei Martianov Avatar answered Nov 18 '25 05:11

Alexei Martianov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!