Replies: 1 comment
-
|
To clarify the proposal, here is how a notebook might look with sink cells: # Cell 0: Normal cell
@app.cell
def _(data):
fig, ax = plt.subplots()
ax.plot(data["x"], data["y"])
# This cell exports 'fig' to the DAG
return (fig,)
# Cell 1: Sink cell
@app.cell(sink=True)
def _(data):
# We can reuse 'fig' and 'ax' names without conflict.
fig, ax = plt.subplots()
ax.plot(data["x"], data["z"])
# This cell does NOT export anything.
return
# Cell 2: Downstream cell
@app.cell
def _(fig):
# This 'fig' correctly refers to Cell 0.
fig
returnThis pattern allows users to perform "throwaway" plotting without having to manually manage unique variable names or prefixes. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I'd like to propose a new feature: "Sink cells" that consume variables from the DAG but do not export any variables.
Problem
When creating many plots in a notebook, we are forced to use the
_prefix to avoid variable name conflicts:When you have 10-20 plots, this becomes ugly and unnatural Python.
Another workaround is wrapping the code in a function, but this also has drawbacks:
_prefix on the function name itself.As noted in #4282 (comment) by @jameskermode, the core issue is not about typing underscores but about cognitive load.
It also makes it harder to copy-paste standard matplotlib/seaborn examples from documentation, as every variable name must be manually prefixed.
This is also a pain point for users migrating from Jupyter Notebook. In Jupyter, you can freely reuse variable names like
figandaxacross cells. Being forced to use_prefixes or unique names in marimo adds friction to the migration.Proposal
Introduce a "sink cell" option, for example
@app.cell(sink=True), where the cell can read variables from other cells but does not export any variables.This means:
With sink cells, the same code becomes:
Clean, natural Python.
UI Suggestion
Sink cells should be visually distinguishable in the editor, for example with a different border color, a leaf icon, or a badge. This way users can instantly see that a cell does not export anything, making the notebook easier to understand at a glance.
Currently, marimo already has cell actions such as "Hide code" in the cell menu. Similarly, a new option could be added to the same cell action menu, allowing users to easily toggle a cell into a sink cell.
I'd love to hear your thoughts on this.
Beta Was this translation helpful? Give feedback.
All reactions