Skip to content

Commit dd83587

Browse files
authored
[App] Resolve run installation (#15974)
1 parent d4be302 commit dd83587

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/lightning_app/cli/cmd_install.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def gallery_apps_and_components(
101101
except Exception:
102102
return None
103103

104-
entry, kind = _resolve_entry(app_or_component, version_arg)
104+
entry, kind = _resolve_entry(name, version_arg)
105105

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

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

116116
elif kind == "component":
117117
# give the user the chance to do a manual install
118-
git_url = _show_install_component_prompt(entry, app_or_component, org, yes_arg)
119-
118+
source_url, git_url, folder_name, git_sha = _show_install_app_prompt(
119+
entry, app_or_component, org, yes_arg, resource_type="component"
120+
)
121+
if "@" in git_url:
122+
git_url = git_url.split("git+")[1].split("@")[0]
120123
# run installation if requested
121-
_install_component_from_source(git_url)
124+
_install_app_from_source(source_url, git_url, folder_name, cwd=cwd, overwrite=overwrite, git_sha=git_sha)
122125

123-
return os.path.join(os.getcwd(), entry["appEntrypointFile"])
126+
return os.path.join(os.getcwd(), *entry["entrypointFile"].split("/"))
124127

125128
return None
126129

tests/tests_app/cli/test_cmd_install.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,18 @@ def test_install_app_shows_error(tmpdir):
321321
# os.chdir(cwd)
322322

323323

324+
def test_app_and_component_gallery_app(monkeypatch):
325+
monkeypatch.setattr(cmd_install, "_install_app_from_source", mock.MagicMock())
326+
path = cmd_install.gallery_apps_and_components("lightning/lightning-diffusion-component-api", True, "latest")
327+
assert path == os.path.join(os.getcwd(), "diffusion2", "app.py")
328+
329+
330+
def test_app_and_component_gallery_component(monkeypatch):
331+
monkeypatch.setattr(cmd_install, "_install_app_from_source", mock.MagicMock())
332+
path = cmd_install.gallery_apps_and_components("lightning/lit-jupyter", True, "latest")
333+
assert path == os.path.join(os.getcwd(), "app.py")
334+
335+
324336
@mock.patch.dict(os.environ, {"LIGHTNING_APP_REGISTRY": "https://TODO/other_non_PL_registry"})
325337
def test_private_app_registry():
326338
registry = cmd_install._resolve_app_registry()

0 commit comments

Comments
 (0)