Skip to content

Commit

Permalink
fix: read sandbox dependencies when opening remote files (#3250)
Browse files Browse the repository at this point in the history
Fixes a bug in which users were prompted for sandbox only when editing
local files.
  • Loading branch information
akshayka authored Dec 20, 2024
1 parent 99ca319 commit e66f93b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions marimo/_cli/sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand Down Expand Up @@ -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,
)
Expand Down
8 changes: 8 additions & 0 deletions tests/_cli/test_sandbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ def test_get_dependencies():
]


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
Expand Down

0 comments on commit e66f93b

Please sign in to comment.