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.95k stars 278 forks source link

Add app-level configuration for autorun on startup #2885

Open wasimsandhu opened 4 days ago

wasimsandhu commented 4 days ago

Description

Having an app-level config for autorun is convenient for users who want some notebooks to run on startup and not others.

Currently, I have to enable and disable this config from marimo home by clicking Settings > User settings > Runtime > Autorun on startup (4 clicks to toggle one setting).

Suggested solution

Here's a quick table showing the expected behavior of these configurations:

User Config App Config Result
Disabled Disabled Notebook does NOT run on launch
Enabled Disabled Notebook does NOT run on launch.
Disabled Enabled Notebook does NOT run on launch.
Enabled Enabled Notebook runs on launch.

TLDR: The notebook can only be autorun on startup if BOTH user config and app config permit it.

Alternative

No response

Additional context

This issue is related to (and is part of the suggested solution for) #2884.

mscolnick commented 4 days ago

Thanks for the request this makes sense. Couple ideas for implementation:

  1. Should we re-use AppConfig and add autorun there? What are the config names? off/default or off/on?
  2. Should we re-use UserConfig and put in the to heading.
    # /// script
    # requires-python = ">=3.11"
    # dependencies = [
    #     "marimo",
    # ]
    # [tool.marimo.runtime]
    # auto_instantiate = false
    # ///

I prefer 2 but it is more work, but 2 will help when we want to support overriding notebook config with by the user's pyprojec.toml. It also allows overriding darkmode and other runtime configuration.

mscolnick commented 4 days ago

I also think we can improve the UX when starting up a notebook that is not instantiated, such as a banner at the top to "Run All" or "Run Markdown", and maybe a lot less yellow everywhere

wasimsandhu commented 3 days ago

I don't have as much context around UserConfig so I'm not sure what you mean when you say to reuse it (in Option 2).

Also, I know it is a separate discussion, but when it comes to pyproject.toml settings, I'm not sure this solves the per-notebook basis that is requested for runtime configurations, since those are project-level settings.

mscolnick commented 3 days ago

"User config" is our MarimoConfig object in the code base, which right now is only set per-user, but we want to add it per-project and per-notebook. By using the pyproject.toml, we can do both, since PEP 723 allows for this.