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
8.17k stars 298 forks source link

Working with external surrounding project deps (with sandbox?) #3008

Open gabrielgrant opened 5 days ago

gabrielgrant commented 5 days ago

Documentation is

Explain in Detail

We work with notebooks within a larger project. Marimo is ideal for this, since it doesn't cause the horrendous diffs we get from Jupyter.

The outer project is managed with poetry. We don't want marimo in the general project deps, and sometimes want additional tools in a notebook for testing/analysis that aren't in project deps. Not finding docs on a good workflow for this

So far been trying out the VSCode extension and pointing it at a separate python venv with marimo installed, then manually adding the project dir to the path within the notebook. This kinda works for simple things, but is fragile and doesn't have project-specific deps. Would be ideal if a workflow/solution would work with the VSCode extension, but not a requirement

Your Suggestion for Changes

It would be great to be able to have the project deps installed and then any notebook-specific deps layered on top all in a single sandbox. Not sure if that's achievable today? Maybe with uv directly? However it's best done, this general pattern of having some notebooks for doing exploratory work within a larger project repo seems like a common patter that it'd be great to see addressed in the docs

mscolnick commented 5 days ago

We don't currently don't support this today. Maybe there is some magic we could do with uv's dependency groups.

The best workaround today would be calling subprocess.run(['uv', 'pip', 'install', '-r', 'requirements.txt']) or specific deps.

Another option is maybe marimo can ship mo.install() (can be fancy to include user confirmation, etc) which would hook into your user-configured package manager.