marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
7.96k stars 278 forks source link

Cell Output Location as Notebook property? #2774

Open riyavsinha opened 2 weeks ago

riyavsinha commented 2 weeks ago

Description

Currently, the cell output location is a user config display property. For some applications, it would be helpful to specify this as an application property that is maintained when sharing the notebook with others. For example, in the chat-notebook I'm trying to build, where the cell input i the LLM prompt, it makes sense to specify at the notebook level that that the LLM cell output should be displayed below.

This should be relatively simple to either move to the application config, or add to the application config and keep overridable by the userconfig, I imagine?

Suggested solution

import marimo

__generated_with = "0.9.14"
app = marimo.App(width="full", cell_output="below")

Alternative

No response

Additional context

No response

mscolnick commented 2 weeks ago

Hi @riyavsinha, your use-case makes sense, and your proposal does too.

I think we can add "below" | "above" | None - none will infer from the users config.

Is this something you'd be open to configuring? If not, we can try to get it in the next few weeks.

riyavsinha commented 2 weeks ago

Yup, on it!

mscolnick commented 2 weeks ago

@riyavsinha - actually rather than using the existing app config, it might be more extensible to use a subset of the UserConfig as a comment in the script metadata (pyproject.toml) that gets put at a comment in the header (like we do for dependencies). This would make config overrides possible and docs/education easier.

This would require more changes so we can handle this @riyavsinha if you'd like, but definitely would still appreciate the contribution.

Thoughts @akshayka?

akshayka commented 2 weeks ago

I think overriding user config in a [tool] table (as per PEP 723) in the inline script metadata makes sense.

Although for this particular config (output location), I don't understand why it's important to enforce at the notebook level.

One config that I think could be helpful to configure at the notebook level is autorun at startup.

  1. Would users edit the metadata by hand for now?
  2. Would we support overriding any user config or just a subset?
mscolnick commented 2 weeks ago
  1. Yes, by hand, but docs on how
  2. Just a subset, documenting which ones. Warning for unsupported/unrecognized at runtime

In my opinion