Skip to main content

Run marimo reactive notebooks on Amazon SageMaker Studio Lab and SageMaker Studio

Project description

marimo on Amazon SageMaker

Run marimo, the reactive Python notebook, on Amazon SageMaker Studio and Studio Lab.

Setup on Studio Lab 5-Minute Setup Python marimo License Version


โšก One-Command Setup

For SageMaker Studio Lab (free, no AWS account required):

curl -fsSL https://raw.githubusercontent.com/scttfrdmn/aws-sagemaker-marimo/main/bootstrap.sh | bash

Then start marimo:

~/start-marimo.sh

๐Ÿ“– Full Bootstrap Guide | โš™๏ธ Manual Setup


โš ๏ธ Known Limitation: WebSocket on SageMaker Studio Lab

marimo's home page loads but notebooks show blank cells or "connecting" status.

This is a known limitation of SageMaker Studio Lab's gateway/ALB infrastructure. HTTP proxying through jupyter-server-proxy works correctly โ€” you can browse marimo's file list โ€” but WebSocket connections (which marimo requires for cell execution) are dropped by the SageMaker gateway on /proxy/PORT/ paths. This affects all WebSocket-dependent proxied applications, not just marimo.

What works:

  • โœ… marimo home page / file browser via /proxy/2718/
  • โœ… HTTP API requests through the proxy
  • โœ… jupyter-server-proxy 4.4.0 (conda default) โ€” no downgrade needed

What doesn't work (without the shim):

  • โŒ Interactive notebook editing (requires WebSocket)
  • โŒ Cell execution and reactive updates (requires WebSocket)

Workaround included: This repo uses ws-sse-proxy to translate WebSocket to SSE, making marimo fully functional on Studio Lab. See WEBSOCKET-STATUS.md for details, or just run:

bash start-marimo-shim.sh
# Then access at /proxy/2719/

Tracking: marimo-jupyter-extension #8 and marimo #8060


๐Ÿš€ Quick Start (5 Minutes)

Want to try marimo right now?

๐Ÿ‘‰ Start with the Quick Start Guide - Get marimo running in 5 minutes on SageMaker Studio Lab (free!) or Studio.

๐Ÿ“š What's Included

This repository provides:

  1. ๐Ÿ“– Complete Blog Post (~2000 words)

    • Deep dive into marimo's features
    • Why use marimo on SageMaker
    • Architecture overview
    • Deployment strategies
    • Best practices and troubleshooting
  2. โšก Quick Start Guide

    • 5-minute setup for Studio Lab (free)
    • Easy installation for Studio
    • Sample notebooks
    • Troubleshooting tips
  3. ๐Ÿ”ง Infrastructure as Code

    • terraform/ - Complete Terraform deployment
    • cdk/ - AWS CDK (Python) deployment
    • Lifecycle configurations
    • Sample notebooks
  4. ๐ŸŽ“ Demo Notebook

    • Complete ML workflow
    • Interactive data exploration
    • Model training with reactive parameters
    • SageMaker integration examples

๐ŸŽฏ Choose Your Path

Path 1: Just Try It (Fastest)

Perfect for: Learning, experimenting, quick demos

  1. Get free SageMaker Studio Lab account
  2. Follow QUICKSTART.md
  3. Try the sample notebook
  4. Total time: ~10 minutes

Path 2: Manual Setup on Studio/Studio Lab

Perfect for: Individual users, existing Studio environment

  1. Open SageMaker Studio or Studio Lab
  2. Run pip install marimo jupyter-server-proxy
  3. Start with marimo edit --host 0.0.0.0 --port 2718 --no-token --headless
  4. See QUICKSTART.md for details
  5. Note: On Studio Lab, WebSocket connections are blocked by the gateway โ€” see known limitation

Path 3: Production Deployment

Perfect for: Teams, production workloads, persistent setup

  1. Read the blog post for architecture understanding
  2. Choose Terraform or CDK
  3. Deploy with one command
  4. Get automated, persistent marimo installation

๐Ÿ’ก Why marimo?

Traditional Jupyter notebooks have well-known issues:

  • โŒ Hidden state from out-of-order execution
  • โŒ JSON format causes Git conflicts
  • โŒ ~75% of notebooks on GitHub don't run
  • โŒ Hard to reproduce research

marimo solves these problems:

  • โœ… Reactive execution - cells auto-update when dependencies change
  • โœ… Stored as pure Python - Git-friendly, executable as scripts
  • โœ… No hidden state - deterministic, reproducible
  • โœ… Interactive UI widgets - no callbacks needed
  • โœ… Three tools in one - notebook, script, and web app

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   SageMaker Studio / Studio Lab     โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  JupyterLab Environment       โ”‚  โ”‚
โ”‚  โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚  โ”‚
โ”‚  โ”‚  โ”‚ jupyter-server-proxy    โ”‚  โ”‚  โ”‚
โ”‚  โ”‚  โ”‚         โ†“                โ”‚  โ”‚  โ”‚
โ”‚  โ”‚  โ”‚ marimo server (:2718)   โ”‚  โ”‚  โ”‚
โ”‚  โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“ฆ Repository Structure

.
โ”œโ”€โ”€ README.md                    # This file
โ”œโ”€โ”€ QUICKSTART.md               # 5-minute setup guide
โ”œโ”€โ”€ BOOTSTRAP.md                # One-command bootstrap guide
โ”œโ”€โ”€ STUDIO-LAB-SETUP.md         # Automated Studio Lab setup
โ”œโ”€โ”€ BADGES.md                   # Badge options for READMEs
โ”œโ”€โ”€ WEBSOCKET-STATUS.md         # WebSocket proxy status & research
โ”œโ”€โ”€ CONTRIBUTING.md             # Contribution guidelines
โ”œโ”€โ”€ CHANGELOG.md                # Version history (Keep a Changelog)
โ”œโ”€โ”€ LICENSE                     # MIT License
โ”œโ”€โ”€ VERSION                     # Semantic version (0.1.0)
โ”œโ”€โ”€ blog-post.md                # Full blog post (~2000 words)
โ”œโ”€โ”€ sagemaker_ml_demo.py        # Complete demo notebook
โ”œโ”€โ”€ bootstrap.sh                # One-command setup script
โ”œโ”€โ”€ start-marimo-shim.sh        # Start marimo with WebSocket shim
โ”œโ”€โ”€ studio-lab-setup.sh         # Setup script with conda env
โ”œโ”€โ”€ terraform/                  # Terraform IaC (coming soon)
โ”œโ”€โ”€ cdk/                        # AWS CDK IaC (coming soon)
โ””โ”€โ”€ notebooks/                  # Sample notebooks (coming soon)

๐ŸŽ“ Sample Notebooks

Quick Demo

import marimo as mo

# Interactive slider
slider = mo.ui.slider(0, 100, value=50)

# Automatically updates when slider changes!
result = slider.value ** 2
mo.md(f"Value: {slider.value}, Squared: {result}")

SageMaker Integration

import marimo as mo
import boto3

sagemaker = boto3.client('sagemaker')

# List training jobs
jobs = sagemaker.list_training_jobs(MaxResults=10)

# Interactive table
mo.ui.table(jobs['TrainingJobSummaries'])

See sagemaker_ml_demo.py for a complete, production-ready example.

๐Ÿšข Deployment Options

Option 1: Terraform

cd terraform
terraform init
terraform apply

Creates:

  • SageMaker Studio Domain
  • VPC and security groups
  • IAM roles
  • Lifecycle configuration for marimo
  • S3 bucket for artifacts

Option 2: AWS CDK

cd cdk
pip install -r requirements.txt
cdk deploy

Same infrastructure as Terraform, using Python CDK constructs.

Option 3: Manual (Quickest)

See QUICKSTART.md - just pip install marimo and go!

๐Ÿ’ฐ Cost Comparison

Option Cost Best For
Studio Lab $0 (100% free) Learning, small projects
Studio (manual) ~$0.05-2/hour Individual use, testing
Studio (IaC) ~$1-5/hour Teams, production

marimo's lightweight architecture means minimal overhead costs.

๐Ÿ”ง Maintenance

Updating marimo

Studio Lab / Manual:

pip install --upgrade marimo

With Lifecycle Config: Update the version in install-marimo.sh and redeploy lifecycle configuration.

Cleanup

Terraform:

terraform destroy

CDK:

cdk destroy

Manual: Just stop using it - no infrastructure to clean up!

๐Ÿค Use Cases

marimo on SageMaker is perfect for:

  • ๐Ÿ”ฌ Reproducible Research - Pure Python format, no hidden state
  • ๐Ÿ‘ฅ Team Collaboration - Git-friendly, version-controlled notebooks
  • ๐Ÿ“Š Interactive Dashboards - Reactive UI updates, deploy as web apps
  • ๐Ÿš€ MLOps Pipelines - Run notebooks as scripts in CI/CD
  • ๐ŸŽ“ Teaching & Demos - Predictable execution, professional output
  • ๐Ÿ” Data Exploration - Interactive filtering and visualization

๐Ÿ†š marimo vs Jupyter

When to use marimo:

  • โœ… Building dashboards or interactive apps
  • โœ… Need reproducible, version-controlled research
  • โœ… Want reactive, automatic updates
  • โœ… Creating reusable modules or pipelines
  • โœ… Teaching or presenting (no hidden state issues)

When to use Jupyter:

  • โœ… Quick ad-hoc exploration
  • โœ… Team heavily invested in Jupyter ecosystem
  • โœ… Need specific Jupyter extensions

Best practice: Use both! Convert between formats as needed with marimo convert.

โ“ Troubleshooting

Common issues and solutions are in QUICKSTART.md.

Quick fixes:

  • Can't access UI: Check proxy URL path
  • Port in use: Use different port (--port 8889)
  • Proxy not working: Run jupyter serverextension enable --py jupyter_server_proxy

๐ŸŽฏ Next Steps

  1. โœ… Try the Quick Start (5 minutes)
  2. โœ… Read the blog post for deep dive
  3. โœ… Run the demo notebook
  4. โœ… Convert your Jupyter notebooks: marimo convert notebook.ipynb
  5. โœ… Deploy with infrastructure-as-code for production use

๐ŸŒŸ Features Showcase

Reactive Execution

# Change slider, everything updates automatically
slider = mo.ui.slider(0, 100)
filtered_data = data[data['value'] > slider.value]
plot = create_plot(filtered_data)  # Auto-updates!

Git-Friendly

# Clean diffs, no JSON
git diff notebook.py

# Run as script
python notebook.py

# Deploy as app
marimo run notebook.py

Interactive UI

# No callbacks needed!
dropdown = mo.ui.dropdown(['A', 'B', 'C'])
table = mo.ui.table(dataframe)
plot = mo.ui.plotly(figure)

๐Ÿ“„ License

This repository: MIT License

marimo: Apache 2.0 License

๐Ÿ™ Acknowledgments

  • marimo team - for building an amazing reactive notebook platform
  • AWS SageMaker team - for creating a flexible ML platform
  • Community - for feedback and contributions

๐Ÿ“ฌ Support


๐Ÿ“š Documentation

๐Ÿ“ Project Info

๐Ÿค Contributing

Contributions are welcome! Please read CONTRIBUTING.md for guidelines.

To contribute:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

See CHANGELOG.md for version history.


Ready to get started?

๐Ÿ‘‰ One command: curl -fsSL https://raw.githubusercontent.com/scttfrdmn/aws-sagemaker-marimo/main/bootstrap.sh | bash

๐Ÿ‘‰ Or manual: QUICKSTART.md

๐Ÿ‘‰ Deep dive: Full blog post

Happy reactive coding! ๐Ÿš€

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aws_sagemaker_marimo-0.2.0.tar.gz (33.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aws_sagemaker_marimo-0.2.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file aws_sagemaker_marimo-0.2.0.tar.gz.

File metadata

  • Download URL: aws_sagemaker_marimo-0.2.0.tar.gz
  • Upload date:
  • Size: 33.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for aws_sagemaker_marimo-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ebc42070b17d041ed83edabbce7913402c8ac6148a5f88bd687ca6a3662c007d
MD5 620708507a099d990825120f68060ffe
BLAKE2b-256 4dcc5ccb141b56c495c17b13f0e175c702ba002ef93311622ee74f2b4eaf40bd

See more details on using hashes here.

File details

Details for the file aws_sagemaker_marimo-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aws_sagemaker_marimo-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7a4c83814749076a1b1da09d05b7a562799a6b525b891020f0a1abfd94c9f2a
MD5 1abc6cfb309c972175de3a33f0136150
BLAKE2b-256 2905b89f9d1cf73203b2e5bf8a223343a79305acd5e6423d50bc24204ca6c0f0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page