From d033972f48510d1ead1b972ec12678dccc1550ab Mon Sep 17 00:00:00 2001 From: Myles Scolnick Date: Fri, 30 Aug 2024 21:23:34 +0200 Subject: [PATCH] example: modal labs (#2158) * example: modal labs * fix --- examples/modal/modal_example.py | 27 +++++++++++++++++++++++++++ examples/modal/nbs/home.py | 20 ++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 examples/modal/modal_example.py create mode 100644 examples/modal/nbs/home.py diff --git a/examples/modal/modal_example.py b/examples/modal/modal_example.py new file mode 100644 index 00000000000..a30bf0ab3f4 --- /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() + + +@app.function( + 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 00000000000..826c80a9e72 --- /dev/null +++ b/examples/modal/nbs/home.py @@ -0,0 +1,20 @@ +import marimo + +__generated_with = "0.8.4" +app = marimo.App() + + +@app.cell +def __(mo): + mo.md("""# Hello, from inside Modal!""") + return + + +@app.cell +def __(): + import marimo as mo + return mo, + + +if __name__ == "__main__": + app.run()