Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

1.7 KB
Raw Blame

Slurm examples

Working examples for running marimo notebooks on Slurm-managed clusters, including Slurm-on-Kubernetes setups like SUNK. See the Slurm deployment guide for the full walkthrough.

Both patterns require uv on PATH (Slurm propagates the submission shell's environment to the job by default).

Interactive: marimo editor on a compute node

run_marimo.sh opens submit_notebook.py; swap in your own notebook path to edit something else.

sbatch run_marimo.sh
squeue -u $USER                      # find the compute node
ssh -L 3000:NODE:3000 you@cluster    # tunnel from your laptop
# open http://localhost:3000

Batch: a notebook that is its own Slurm job

submit_notebook.py is simultaneously a marimo notebook, a Python script, and an sbatch submission — the #SBATCH directives, the dependencies (PEP 723), and the code travel in one file:

chmod +x submit_notebook.py
sbatch submit_notebook.py --n 500000

The --script flag in the shebang lets uv run Slurm's spooled, extensionless copy of the file.

Tips for shared clusters:

  • uv's wheel cache lives in ~/.cache/uv; point UV_CACHE_DIR at a shared or project filesystem so compute nodes reuse downloads.
  • If your home and cache live on different mounts, set UV_LINK_MODE=copy.
  • mo.persistent_cache writes to __marimo__/cache/ next to the notebook. If that directory is not writable, it will write under the job's working directory instead. If you use the cache, consider launching jobs from a shared file system, such that resubmissions will correctly skip completed work.