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.

example: modal labs (#2158)

Myles Scolnickd033972f4851
diff --git a/examples/modal/modal_example.py b/examples/modal/modal_example.py
new file mode 100644
index 0000000000..a30bf0ab3f
--- /dev/null
+++ b/examples/modal/modal_example.py
@@ -0,0 +1,27 @@
+from __future__ import annotations
+
+import modal
+from modal import asgi_app
+
+import marimo
+
+server = marimo.create_asgi_app().with_app(path="", root="/marimo/home.py")
+
+app = modal.App()
+
+
+ image=modal.Image.debian_slim().pip_install("marimo>=0.8.3", "fastapi"),
+ gpu=False,
+ concurrency_limit=1,
+ allow_concurrent_inputs=2,
+ memory=256,
+ mounts=[modal.Mount.from_local_dir("./nbs", remote_path="/marimo")],
+)
+@asgi_app()
+def marimo_asgi():
+ return server.build()
+
+
+if __name__ == "__main__":
+ modal.serve(app)
diff --git a/examples/modal/nbs/home.py b/examples/modal/nbs/home.py
new file mode 100644
index 0000000000..826c80a9e7
--- /dev/null
+++ b/examples/modal/nbs/home.py
@@ -0,0 +1,20 @@
+import marimo
+
+__generated_with = "0.8.4"
+app = marimo.App()
+
+
+def __(mo):
+ mo.md("""# Hello, from inside Modal!""")
+ return
+
+
+def __():
+ import marimo as mo
+ return mo,
+
+
+if __name__ == "__main__":
+ app.run()