breathe / NotebookScripter

Expose ipython jupyter notebooks as callbable functions or running scripts
MIT License
26 stars 1 forks source link

Replace skip_cell api with merge_injected_dictionary #2

Closed breathe closed 5 years ago

breathe commented 5 years ago

Currently parameters are passed into notebooks by marking cells with skip_cell metadata. This in combination with injection of values into the module scope provides a cludgy way for the notebook to be parameterized externally.

There are some problems with this approach:

A better version of this api would allow merging values from caller provided dictionary into module scope at a time chosen by the notebook author and would always run every cell in the notebook.

New api:

  1. Author marks cell with metadata “NotebookScripter.HookPoint”: “hookName”
  2. run_notebook() is changed to take **hookArgs — where each hook value must be something that could be passed to dict.update() method. Provided mappings will be merged into the notebook’s module scope after the corresponding cell runs