btnaughton
btnaughton
Mmarimo
Created by btnaughton on 8/28/2024 in #help-support
running marimo on modal
I actually posted this to github discussions, so apologies for double-positng. I think this is probably a better forum for this question... (Happy to delete the github one if that's helpful) I am trying to get marimo running on modal, following https://docs.marimo.io/guides/deploying/programmatically.html and https://docs.marimo.io/guides/deploying/authentication.html The following code works, up to the point of giving a 401 for /api/kernel/instantiate
import modal
from modal import asgi_app
import marimo

server = marimo.create_asgi_app().with_app(path="", root="/marimo/test.py")

app = modal.App()

@app.function(
image=modal.Image.debian_slim().pip_install("marimo==0.8.3", "fastapi"),
gpu=False,
mounts=[modal.Mount.from_local_dir("./marimo", remote_path="/marimo")],
)
@asgi_app()
def marimo_asgi():
return server.build()


if __name__ == "__main__":
modal.serve(app)
import modal
from modal import asgi_app
import marimo

server = marimo.create_asgi_app().with_app(path="", root="/marimo/test.py")

app = modal.App()

@app.function(
image=modal.Image.debian_slim().pip_install("marimo==0.8.3", "fastapi"),
gpu=False,
mounts=[modal.Mount.from_local_dir("./marimo", remote_path="/marimo")],
)
@asgi_app()
def marimo_asgi():
return server.build()


if __name__ == "__main__":
modal.serve(app)
I have tried adding middleware and I can see the requests come through. I can reject requests (return 401) but I can't figure out how to prevent a 401 for /api/kernel/instantiate
GET / -> 200 OK (duration: 117.8 ms, execution: 51.9 ms)
....
GET /android-chrome-192x192.png -> 200 OK (duration: 1.27 s, execution: 0.0 ms)
POST /api/kernel/instantiate -> 401 Unauthorized (duration: 1.17 s, execution: 13.1 ms)
CONNECT /ws -> 101 Switching Protocols (duration: 1.52 s, execution: 0.0 ms)
GET / -> 200 OK (duration: 117.8 ms, execution: 51.9 ms)
....
GET /android-chrome-192x192.png -> 200 OK (duration: 1.27 s, execution: 0.0 ms)
POST /api/kernel/instantiate -> 401 Unauthorized (duration: 1.17 s, execution: 13.1 ms)
CONNECT /ws -> 101 Switching Protocols (duration: 1.52 s, execution: 0.0 ms)
I think I am missing something fundamental about what's going on here, since I don't see where a token could be validated, or where the 401 is actually happening. I do see marimo-server-token in the header for /api/kernel/instantiate but no authorization or similar. If anyone has any ideas, I would appreciate it! Running marimo on modal would be fantastic.
27 replies