Skip to content

Add marimo MNIST + W&B Registry example#621

Open
johndmulhausen wants to merge 2 commits into
masterfrom
jmulhausen/marimo-mnist-registry-example
Open

Add marimo MNIST + W&B Registry example#621
johndmulhausen wants to merge 2 commits into
masterfrom
jmulhausen/marimo-mnist-registry-example

Conversation

@johndmulhausen
Copy link
Copy Markdown

Summary

Adds the first marimo notebook to this repo at examples/marimo/mnist-registry/. The notebook trains a small PyTorch CNN on MNIST, logs the run to W&B, saves the trained weights as a model Artifact, and links the Artifact to a W&B Registry collection through the current cross-org run.link_artifact(target_path="wandb-registry-model/<collection>") API.

PEP 723 inline script metadata makes the notebook self-installing under uvx marimo edit mnist_registry.py --sandbox. No new top-level deps for the repo.

What the notebook demonstrates

  • Form-driven hyperparameters. mo.ui widgets bind to a config dict that feeds wandb.config.
  • Button-gated training. mo.ui.run_button plus mo.stop keeps slider tweaks from kicking off runs. After a run completes, clicking again starts a new run using the current form values; the previous run finishes cleanly first.
  • Defensive run lifecycle. wandb.finish() runs at the top of the training cell and at the end of the notebook so re-clicking Train in the same marimo kernel never nests runs.
  • Cross-org Registry linking. run.link_artifact(artifact=logged, target_path=f"wandb-registry-{registry}/{collection}") with a try/except that surfaces inline remediation guidance when the Registry is not provisioned, rather than crashing.
  • logged.wait() before linking prevents a race where link_artifact resolves an uncommitted version.
  • wandb.define_metric uses epoch as the x-axis for train/* and test/* series in the W&B UI.

Architecture and training loop mirror examples/pytorch/pytorch-cnn-mnist/main.py. Registry linking mirrors colabs/wandb_registry/zoo_wandb.ipynb.

Files

  • examples/marimo/mnist-registry/mnist_registry.py — the notebook (~640 lines)
  • examples/marimo/mnist-registry/README.md — prereqs, how to run, design notes
  • examples/marimo/mnist-registry/requirements.txt — pip mirror of the PEP 723 block

Commits

  1. add marimo MNIST + W&B Registry example — initial draft
  2. apply Google Developer Style Guide pass to marimo MNIST example — style cleanup (active voice, present tense, plain English, brand capitalization, code identifiers in backticks)

Test plan

  • python3 -c "import ast; ast.parse(open('examples/marimo/mnist-registry/mnist_registry.py').read())" succeeds (verified locally).
  • uvx marimo edit examples/marimo/mnist-registry/mnist_registry.py --sandbox opens the notebook with all cells rendering and no errors.
  • Hyperparameter form is interactive; nudging sliders does not start training before Train model is clicked.
  • Clicking Train model with defaults (3 epochs, batch 64, lr 0.01) starts a W&B run, completes in about two minutes on CPU, reaches >97% test accuracy.
  • An artifact mnist-cnn-<run-id> appears under the run's Artifacts tab with metadata for test accuracy, parameter count, and hyperparameters.
  • The Registry cell reports a successful link to wandb-registry-model/MNIST Classifiers; the version appears in the Model registry UI.
  • Changing a slider after the first run and clicking Train model again starts a new run cleanly (no wandb.init warnings about a pre-existing run).
  • Pointing the Registry name field at a non-existent registry surfaces a red mo.callout with remediation guidance and does not crash the notebook.
  • Unchecking Link artifact to Registry still produces a logged Artifact, with the Registry cell reporting that linking was skipped.

🤖 Generated with Claude Code

johndmulhausen and others added 2 commits May 13, 2026 12:16
Introduces the first marimo notebook in this repo. Trains a small PyTorch CNN
on MNIST, logs the run with wandb, saves the trained model as an Artifact,
and links it to a W&B Registry collection via the cross-org link_artifact
API.

The notebook is interactive: hyperparameters live in a marimo form and
training is gated by an explicit Train button so slider tweaks do not
trigger runs. PEP 723 inline script metadata makes it self-installing
under `uvx marimo edit --sandbox`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Active voice, present tense, plain English, and consistent brand
capitalization across the README and the notebook's prose cells.
Code identifiers wrapped in backticks where missing; a sentence
fragment in the verify step rewritten as a complete clause.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedmarimo@​0.23.672100100100100

View full report

@socket-security
Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn High
License policy violation: pypi marimo

Location: Package overview

From: examples/marimo/mnist-registry/requirements.txtpypi/marimo@0.23.6

ℹ Read more on: This package | This alert | What is a license policy violation?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Find a package that does not violate your license policy or adjust your policy to allow this package's license.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/marimo@0.23.6. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
License policy violation: pypi marimo

Location: Package overview

From: examples/marimo/mnist-registry/requirements.txtpypi/marimo@0.23.6

ℹ Read more on: This package | This alert | What is a license policy violation?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Find a package that does not violate your license policy or adjust your policy to allow this package's license.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore pypi/marimo@0.23.6. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant