marimo icon indicating copy to clipboard operation
marimo copied to clipboard

Add app-level configuration for autorun on startup

Open wasimxyz opened this issue 1 year ago • 4 comments

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.

wasimxyz avatar Nov 18 '24 01:11 wasimxyz

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 avatar Nov 18 '24 14:11 mscolnick

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

mscolnick avatar Nov 18 '24 14:11 mscolnick

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.

wasimxyz avatar Nov 18 '24 18:11 wasimxyz

"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.

mscolnick avatar Nov 18 '24 18:11 mscolnick