Skip to content

Commit 1ac3480

Browse files
rlizzolexierule
authored andcommitted
Fix: Start Lightning App on Cloud if Repo Begins With Name "Lightning" (#14025)
(cherry picked from commit b4ade23)
1 parent aba2cbd commit 1ac3480

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/lightning_app/utilities/packaging/lightning_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,13 @@ def get_dist_path_if_editable_install(project_name) -> str:
8989

9090

9191
def _prepare_lightning_wheels_and_requirements(root: Path) -> Optional[Callable]:
92+
"""This function determines if lightning is installed in editable mode (for developers) and packages the
93+
current lightning source along with the app.
9294
93-
if "site-packages" in _PROJECT_ROOT:
95+
For normal users who install via PyPi or Conda, then this function does not do anything.
96+
"""
97+
98+
if not get_dist_path_if_editable_install("lightning"):
9499
return
95100

96101
# Packaging the Lightning codebase happens only inside the `lightning` repo.

tests/tests_app/utilities/packaging/test_lightning_utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
from unittest import mock
23

34
import pytest
45

@@ -21,6 +22,21 @@ def test_prepare_lightning_wheels_and_requirement(tmpdir):
2122
assert os.listdir(tmpdir) == []
2223

2324

25+
def _mocked_get_dist_path_if_editable_install(*args, **kwargs):
26+
return None
27+
28+
29+
@mock.patch(
30+
"lightning_app.utilities.packaging.lightning_utils.get_dist_path_if_editable_install",
31+
new=_mocked_get_dist_path_if_editable_install,
32+
)
33+
def test_prepare_lightning_wheels_and_requirement_for_packages_installed_in_editable_mode(tmpdir):
34+
"""This test ensures the source does not get packaged inside the lightning repo if not installed in editable
35+
mode."""
36+
cleanup_handle = _prepare_lightning_wheels_and_requirements(tmpdir)
37+
assert cleanup_handle is None
38+
39+
2440
@pytest.mark.skip(reason="TODO: Find a way to check for the latest version")
2541
@RunIf(skip_windows=True)
2642
def test_verify_lightning_version(monkeypatch):

0 commit comments

Comments
 (0)