diff --git a/src/lightning_app/CHANGELOG.md b/src/lightning_app/CHANGELOG.md index 8c830c62ef..7439d6a4be 100644 --- a/src/lightning_app/CHANGELOG.md +++ b/src/lightning_app/CHANGELOG.md @@ -37,6 +37,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Fixed `AutoScaler` failing due to port collision across works ([#15966](https://github.com/Lightning-AI/lightning/pull/15966)) +- Fixed a bug where auto-upgrading to the latest lightning via the CLI could get stuck in a loop ([#15984](https://github.com/Lightning-AI/lightning/pull/15984)) + + - Fixed Registration for CloudComputes of Works in `L.app.structures` ([#15964](https://github.com/Lightning-AI/lightning/pull/15964)) diff --git a/src/lightning_app/cli/lightning_cli.py b/src/lightning_app/cli/lightning_cli.py index 11138ea6fb..87b0ef9175 100644 --- a/src/lightning_app/cli/lightning_cli.py +++ b/src/lightning_app/cli/lightning_cli.py @@ -49,8 +49,9 @@ logger = Logger(__name__) def main() -> None: - # Check environment and versions if not in the cloud - if "LIGHTNING_APP_STATE_URL" not in os.environ: + # Check environment and versions if not in the cloud and not testing + is_testing = bool(int(os.getenv("LIGHTING_TESTING", "0"))) + if not is_testing and "LIGHTNING_APP_STATE_URL" not in os.environ: # Enforce running in PATH Python _check_environment_and_redirect() diff --git a/src/lightning_app/testing/testing.py b/src/lightning_app/testing/testing.py index 8d112d7fa4..40b705458d 100644 --- a/src/lightning_app/testing/testing.py +++ b/src/lightning_app/testing/testing.py @@ -262,6 +262,7 @@ def run_app_in_cloud( with tempfile.TemporaryDirectory() as tmpdir: env_copy = os.environ.copy() env_copy["PACKAGE_LIGHTNING"] = "1" + env_copy["LIGHTING_TESTING"] = "1" if debug: env_copy["LIGHTNING_DEBUG"] = "1" shutil.copytree(app_folder, tmpdir, dirs_exist_ok=True) diff --git a/src/lightning_app/utilities/cli_helpers.py b/src/lightning_app/utilities/cli_helpers.py index 293944ca82..caa414e163 100644 --- a/src/lightning_app/utilities/cli_helpers.py +++ b/src/lightning_app/utilities/cli_helpers.py @@ -254,7 +254,7 @@ def _get_newer_version() -> Optional[str]: return None if __version__ == latest_version else latest_version except Exception: # Return None if any exception occurs - return "err" + return None def _redirect_command(executable: str): @@ -277,7 +277,7 @@ def _check_version_and_upgrade(): prompt = f"A newer version of {__package_name__} is available ({new_version}). Would you like to upgrade?" if click.confirm(prompt, default=True): - command = f"pip install --upgrade {__package_name__}" + command = f"pip install '{__package_name__}=={new_version}'" logger.info(f"⚡ RUN: {command}") diff --git a/tests/tests_app/utilities/test_cli_helpers.py b/tests/tests_app/utilities/test_cli_helpers.py index 4ebb3ddc4f..ecdd1705c2 100644 --- a/tests/tests_app/utilities/test_cli_helpers.py +++ b/tests/tests_app/utilities/test_cli_helpers.py @@ -99,7 +99,7 @@ def test_arrow_time_callback(): "1.0.0dev", None, ), - ({"1.0.0": "this wil trigger an error"}, "1.0.0", "err"), + ({"1.0.0": "this wil trigger an error"}, "1.0.0", None), ({}, "1.0.0rc0", None), ], )