github marimo-team/marimo 0.2.9

latest releases: 0.11.8, 0.11.7, 0.11.6...
12 months ago

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:

image

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.

New Contributors

  • @scls19fr made their first contribution in #832

Full Changelog: 0.2.8...0.2.9

Don't miss a new marimo release

NewReleases is sending notifications on new releases.