Skip to content

Commit

Permalink
[App] Resolve run installation (#15974)
Browse files Browse the repository at this point in the history
  • Loading branch information
tchaton authored Dec 9, 2022
1 parent d4be302 commit dd83587
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/lightning_app/cli/cmd_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def gallery_apps_and_components(
except Exception:
return None

entry, kind = _resolve_entry(app_or_component, version_arg)
entry, kind = _resolve_entry(name, version_arg)

if kind == "app":
# give the user the chance to do a manual install
Expand All @@ -111,16 +111,19 @@ def gallery_apps_and_components(
# run installation if requested
_install_app_from_source(source_url, git_url, folder_name, cwd=cwd, overwrite=overwrite, git_sha=git_sha)

return os.path.join(os.getcwd(), folder_name, entry["appEntrypointFile"])
return os.path.join(os.getcwd(), *entry["appEntrypointFile"].split("/"))

elif kind == "component":
# give the user the chance to do a manual install
git_url = _show_install_component_prompt(entry, app_or_component, org, yes_arg)

source_url, git_url, folder_name, git_sha = _show_install_app_prompt(
entry, app_or_component, org, yes_arg, resource_type="component"
)
if "@" in git_url:
git_url = git_url.split("git+")[1].split("@")[0]
# run installation if requested
_install_component_from_source(git_url)
_install_app_from_source(source_url, git_url, folder_name, cwd=cwd, overwrite=overwrite, git_sha=git_sha)

return os.path.join(os.getcwd(), entry["appEntrypointFile"])
return os.path.join(os.getcwd(), *entry["entrypointFile"].split("/"))

return None

Expand Down
12 changes: 12 additions & 0 deletions tests/tests_app/cli/test_cmd_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,18 @@ def test_install_app_shows_error(tmpdir):
# os.chdir(cwd)


def test_app_and_component_gallery_app(monkeypatch):
monkeypatch.setattr(cmd_install, "_install_app_from_source", mock.MagicMock())
path = cmd_install.gallery_apps_and_components("lightning/lightning-diffusion-component-api", True, "latest")
assert path == os.path.join(os.getcwd(), "diffusion2", "app.py")


def test_app_and_component_gallery_component(monkeypatch):
monkeypatch.setattr(cmd_install, "_install_app_from_source", mock.MagicMock())
path = cmd_install.gallery_apps_and_components("lightning/lit-jupyter", True, "latest")
assert path == os.path.join(os.getcwd(), "app.py")


@mock.patch.dict(os.environ, {"LIGHTNING_APP_REGISTRY": "https://TODO/other_non_PL_registry"})
def test_private_app_registry():
registry = cmd_install._resolve_app_registry()
Expand Down

0 comments on commit dd83587

Please sign in to comment.