What's Changed
New feature: Importable and runnable cells.
It's now possible to import cells defined in one notebook into other Python files and run them as functions.
This has two key benefits:
🧩 modularity: this lets you re-use notebook logic as you would regular Python code, wherever you like -- in other notebooks or Python files
🔬 testing: this makes it possible, and easy, to test notebook logic using tools like pytest
Check out the documentation for a full reference, or the below for an overview.
To use this feature, you first must name a cell -- either through the cell action menu, or by editing the name of the cell in the notebook file. For example, here we name a cell greetings
:
Then to use the named cell in another notebook, just import it and call its run
method:
# import a cell called greetings
from my_notebook import greetings
# output is the cell's last expression -- in this case, the markdown
# definitions is a mapping of the cell's definition names to their values
output, definitions = greetings.run()
You can also substitute values for the cell's references. For example, to greet someone else:
output, definitions = greetings.run(name="Alice")
This release also includes a number of bug fixes and improvements.
- fix: refresh docs by @mscolnick in #835
- Update refresh.py by @scls19fr in #832
- update: refresh plugin to allow 100ms by @mscolnick in #837
- fix: wasm notebooks on ff by @mscolnick in #839
- feat: vertical slider by @mscolnick in #838
- improvement: support completions in wasm by @mscolnick in #842
- Fix: form internal value by @akshayka in #841
- improvement: improved shortcut symbols by @mscolnick in #844
- improvement: Add scroll lock to bottom of console output by @mscolnick in #828
- feat: import and run named cells by @akshayka in #843
- fix: show stale save after layout edit, add scroll to bordered grid by @mscolnick in #850
- 0.2.9 by @akshayka in #851
New Contributors
- @scls19fr made their first contribution in #832
Full Changelog: 0.2.8...0.2.9