marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
5.31k stars 155 forks source link

Support custom base URL paths, redux (for `marimo edit`) #1648

Closed jyio closed 1 week ago

jyio commented 1 week ago

Description

TL;DR: Could marimo edit be used with a custom base URL path to enable remote access through a path-based reverse proxy?

Thank you for creating and sharing Marimo. Reactive Python is awesome!

Now, I'd love to integrate Marimo with the rest of my stack, including the path-based reverse proxy in JupyterHub (I know, I know...). Allowing custom base URL paths would enable remote access to Marimo through most HTTP reverse proxies. For example, a reverse proxy at example.com might make Marimo available under http(s)://example.com/path/to/marimo/, and Marimo would be configured to accept the /path/to/marimo/ prefix and generate all hyperlinks with the /path/to/marimo/ prefix.

It is already possible to use marimo run with a --base-url parameter to specify a path prefix, as implemented in https://github.com/marimo-team/marimo/pull/748. Adding similar functionality to marimo edit would make most (all?) of Marimo accessible through most reverse proxies.

Why JupyterHub in particular? Marimo is currently a single-tenant single-user app. Multiuser functionality would greatly amplify Marimo's utility, but requires a lot of work (and may even be out of scope of a notebook). JupyterHub could be used as a stop-gap measure to handle the authN/authZ, automatically spawn a Marimo instance for each user on demand, and even provide container-level isolation if desired. It would still be good to have a purpose-built Marimo-hub eventually, but JupyterHub compatibility would relieve the pressure in the near term (and I imagine it would go a long way).

Suggested solution

Give marimo edit the ability to accept a custom base URL (and generate all hyperlinks with the same prefix), similar to marimo run https://github.com/marimo-team/marimo/pull/748.

And, since the editor also supports notebook creation, also consider adding the feature to marimo new.

Alternative

Wait for the multiheaded Marimo-hub 😅

Additional context

No response

mscolnick commented 1 week ago

@jyio - i have the PR up https://github.com/marimo-team/marimo/pull/1651

I am not familiar with running my own JupyterHub - would you be open to contributing a "How To" doc running marimo with JupyterHub (once you have it all set up) that we can add to our docs. if easier, you can add it to this issue https://github.com/marimo-team/marimo/issues/905 and we can convert it to our docs

jyio commented 1 week ago

This is awesome! Thank you! And... confirmed working with JupyterHub.

Yes of course I would write up the instructions. To make this a little easier, I'm looking into creating a convenience package that you could just pip install without having to mess with the jupyterhub_config.py. And, since JupyterHub is a bit of a beast, I'd want to create a minimal reproducible Dockerfile to set up this JupyterHub + Marimo combo. Coming soon :)

mscolnick commented 1 week ago

that would be awesome! let us know if you'd like to make it in the marimo-team org which could help with discoverability. otherwise, we can link our docs to the project

jyio commented 1 week ago

Oh yeah, adopting this integration into marimo-team would definitely encourage people to try it more than "just install this random package from the internet," and I'm all for it. On the flip side, as you say, having another combination to test would add more speed bumps in the way of developer velocity, so I'd also be fine with leaving it in the wild until the team feels ready to take it on (and we'd make it clear that it's "unofficial" but it'd be good to have permission to use the Marimo name and logo). I'm easy to satisfy 😅