simonmaris
simonmaris2mo ago

sandbox with multiple notebooks

We run marimo in a docker container using the following command:
marimo edit --sandbox --no-token -p $PORT --host $HOST
marimo edit --sandbox --no-token -p $PORT --host $HOST
Works fine and we have a folder mounted with several notebooks, which have script metadata, per PEP 723. However, the specified versions are ignored, instead required packages are just auto discovered. It seems sandbox only works properly when directly opening a specific notebook on marimo cmd? 1) Any best practices or ideas for this case? 2) Next level: if those notebooks needed seperate environments, how would you approach this? Any help appreciated - thanks!
7 Replies
Akshay
Akshay2mo ago
It seems sandbox only works properly when directly opening a specific notebook on marimo cmd?
Oh interesting ... I think you're right. Getting it to work for the general edit server may be tricky ...
Next level: if those notebooks needed seperate environments, how would you approach this?
We haven't designed a solution for this yet, but I totally see why it would be useful.
simonmaris
simonmarisOP2mo ago
Ok, thanks for looking into this. I will have to think about a temporary solution with multiple manually managed environments with their own requirements.txt then, maybe I can create and activate them in the first cell using subcommand.run… Shall I create a feature request for auto switching between dynamic sandboxes on the edit server on notebook change?
Akshay
Akshay2mo ago
Shall I create a feature request for auto switching between dynamic sandboxes on the edit server on notebook change?
Yes, you're welcome to! Thanks. I can't promise we'll solve this soon, but it's good to track.
simonmaris
simonmarisOP2mo ago
Would be lovely since we can then really utilize the power of UV with it's global cache ok, will do
simonmaris
simonmarisOP2mo ago
GitHub
make sandbox compatibel with edit server (multiple notebooks) · Iss...
Description Currently --sandbox works great for single notebooks. However, when you start the edit server, two problems occur: we have one isolated environment for all the notebooks the script meta...
simonmaris
simonmarisOP2mo ago
@Akshay Do you have a quick tip on another solution that already works with the edit server? Would it detect .venv directories or something else if I put each notebook in a subfolder? Or is the only way to switch environments currently to restart marimo from CLI? That would be less convenient in a docker container.. 🙂
Akshay
Akshay2mo ago
Or is the only way to switch environments currently to restart marimo from CLI?
This is the only way right now :/ We're aware that a decoupling of kernel from server is something that many people are interested in. In terms of a workaround, I did see this on LinkedIn ... to me it seems like it could have surprising edge cases. But maybe it could unblock you: https://www.linkedin.com/feed/update/urn:li:activity:7250602323402502144/
Alexander Kislukhin, PhD on LinkedIn: #jupyter #python
marimo notebooks don't have kernels. In #jupyter notebooks, kernels are pointers (paths) to #python executables, allowing you to open jupyter's much-beloved…