Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: read sandbox dependencies when opening remote files (#3250)

Akshay Agrawale66f93b5a41a
diff --git a/marimo/_cli/sandbox.py b/marimo/_cli/sandbox.py
index f1c8defa25..65d2dad146 100644
--- a/marimo/_cli/sandbox.py
+++ b/marimo/_cli/sandbox.py
@@ -106,8 +106,9 @@ def _pyproject_toml_to_requirements_txt(
def get_dependencies_from_filename(name: str) -> List[str]:
- if not name or not os.path.exists(name):
+ if not name:
return []
+
try:
contents, _ = FileContentReader().read_file(name)
return _get_dependencies(contents) or []
@@ -185,7 +186,8 @@ def prompt_run_in_sandbox(name: str | None) -> bool:
"This notebook has inlined package dependencies.\n"
+ green(
"Run in a sandboxed venv containing this notebook's "
- "dependencies?"
+ "dependencies?",
+ bold=True,
),
default=True,
)
diff --git a/tests/_cli/test_sandbox.py b/tests/_cli/test_sandbox.py
index be11bfd0cd..eaf60ec0a3 100644
--- a/tests/_cli/test_sandbox.py
+++ b/tests/_cli/test_sandbox.py
@@ -37,6 +37,14 @@ app = marimo.App(width="medium")
]
+def test_get_dependencies_github():
+ url = "https://github.com/marimo-team/marimo/blob/a1e1be3190023a86650904249f911b2e6ffb8fac/examples/third_party/leafmap/leafmap_example.py"
+ assert get_dependencies_from_filename(url) == [
+ "leafmap==0.41.0",
+ "marimo",
+ ]
+
+
def test_no_dependencies():
SCRIPT = """
import marimo