Get help from the marimo community

Updated last week

Execution Order

I thought asking this here before opening an issue on github.

Consider this notebook with these cells.
(it is a versy small simplified version of hg agents course)

I have attached the screenshot of dependencis,

  1. Cell-1 should be run before cell-2. but as in this there are no explicit dependency between them and the cell-2 is getting the env variables underhood we can not guarantee this execution order.
easy solution to solve this problem is mergin cell-1 and cell-2, but for the next problem we can not do that.

  1. Cell-2 should run before cell-5 and cell-4
to be able to monitor the agent. Again this order is not guaranteed.
One dirty solution would be to define a variable in Cell-2 and reference it in Cell-5 and Cell-4.

Does Marimo provides a proper solution for this promblem?
Attachment
image.png
A
H
e
8 comments
We are introducing the concept of a “setup cell” which is guaranteed to run before all other cells. Would that work? In this case cell 2 could I believe be made the setup cell.

cc @dmad , who is designing this feature
Yes, if I merge cell-1 and cell-2 and make cell-2 the setup cell. Yes it would work. thank you
Looks like cell-2 just adds logging?

personally I would throw in something like assert trace_provider is not None in the cell that expects it to be setup
I just take a look at PR of setup cell:
"""Provides a context manager to initialize the setup cell.
This block should only be utilized at the start of a marimo notebook.
It's used as following:
Plain Text
        with app.setup:
            import my_libraries
            from typing import Any
            CONSTANT = "my constant"
        

"""

I was wondering if it has a mechanism to stop the execution of the remaining cells.

For example, if the following in setup
Plain Text
from huggingface_hub import login

login(os.environ["HF_TOKEN"])


fails to login there is no point to execute the rest of the notebook
I mean something similar to mo.stop but to stop all cells. eg: mo.stop_all
Marimo already does that actually
Hmm, in Marimo if a cell fails all child cells would stop, and as setup cell is the parent (ancestor, ..) of all other cells, they would stop executing. right?
Oh sorry, I guess the setup cell may not have definitions that are refs of others. But perhaps it does make sense to gate the entire notebook on the setup cell executing without error
Add a reply
Sign up and join the conversation on Discord