Skip to content

mo.app_meta().mode should be "edit" for marimo export session #12156

Backlog

Description

@rambip

Describe the bug

Say I have a notebook notebook.py that generates some images.
I run the marimo export session notebook.py to get the json output.

If inside I run the mo.app_meta().mode == "edit" check, it will output yes. But it is weird in this case, because there was no interaction with the browser.

Having mode == "export" would also allow me to have a different execution when run from the cli, for example, to not block on a "run" button.

Will you submit a PR?

  • Yes

Environment

N/A

Code to reproduce

N/A

Activity

  1. added theissue type on Nov 29, 2026
  2. added
    bug
    on Nov 29, 2026
  3. rambip commented on Nov 29, 2026

    @rambip
    Author

    I'm not able to add a label to the PR

  4. akshayka commented on Nov 30, 2026

    @akshayka
    Contributor

    @rambip, thanks for the feedback.

    1. This isn't a bug.
    2. You can accomplish what you want without making any changes to marimo's repository, by using Python's support for command-line arguments. Here is an example.

    Pass a command-line argument to marimo export session. For example, export=true

    marimo export session my_nb.py -- -export=true
    

    In your notebook, read the argument vector with sys.argv.

    Since you are comfortable with Python, you can also use higher-level APIs should you wish, such as argparse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions