From 0f7c6085a96174126cca84dd8909e78be423fb13 Mon Sep 17 00:00:00 2001 From: Ethan Harris Date: Fri, 9 Dec 2022 22:22:42 +0000 Subject: [PATCH 1/2] Dont try to update an instance that isnt running yet (#15998) --- src/lightning_app/components/serve/streamlit.py | 1 + src/lightning_app/core/app.py | 7 ++----- src/lightning_app/utilities/app_helpers.py | 9 +++++++-- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/lightning_app/components/serve/streamlit.py b/src/lightning_app/components/serve/streamlit.py index 1a325d60fecee..9b943a1708fa3 100644 --- a/src/lightning_app/components/serve/streamlit.py +++ b/src/lightning_app/components/serve/streamlit.py @@ -58,6 +58,7 @@ def run(self) -> None: ], env=env, ) + self._process.wait() def on_exit(self) -> None: if self._process is not None: diff --git a/src/lightning_app/core/app.py b/src/lightning_app/core/app.py index d9389ecd27e24..47055c70f7f4b 100644 --- a/src/lightning_app/core/app.py +++ b/src/lightning_app/core/app.py @@ -526,14 +526,11 @@ def _update_layout(self) -> None: component._layout = layout def _update_is_headless(self) -> None: - is_headless = _is_headless(self) + self.is_headless = _is_headless(self) # If `is_headless` changed, handle it. # This ensures support for apps which dynamically add a UI at runtime. - if self.is_headless != is_headless: - self.is_headless = is_headless - - _handle_is_headless(self) + _handle_is_headless(self) def _apply_restarting(self) -> bool: self._reset_original_state() diff --git a/src/lightning_app/utilities/app_helpers.py b/src/lightning_app/utilities/app_helpers.py index 665c50889676c..83b78e1929aa5 100644 --- a/src/lightning_app/utilities/app_helpers.py +++ b/src/lightning_app/utilities/app_helpers.py @@ -19,7 +19,7 @@ import websockets from deepdiff import Delta -from lightning_cloud.openapi import AppinstancesIdBody, Externalv1LightningappInstance +from lightning_cloud.openapi import AppinstancesIdBody, Externalv1LightningappInstance, V1LightningappInstanceState import lightning_app from lightning_app.utilities.exceptions import LightningAppStateException @@ -556,7 +556,12 @@ def _handle_is_headless(app: "LightningApp"): "App was not found. Please open an issue at https://github.com/lightning-AI/lightning/issues." ) - if current_lightningapp_instance.spec.is_headless == app.is_headless: + if any( + [ + current_lightningapp_instance.spec.is_headless == app.is_headless, + current_lightningapp_instance.status.phase != V1LightningappInstanceState.RUNNING, + ] + ): return current_lightningapp_instance.spec.is_headless = app.is_headless From 2f39c0110c8b503e97896ac81a651e0ff192c114 Mon Sep 17 00:00:00 2001 From: Ethan Harris Date: Fri, 9 Dec 2022 23:23:19 +0000 Subject: [PATCH 2/2] Fix hanging CI --- src/lightning_app/testing/config.py | 2 +- tests/tests_examples_app/public/test_boring_app.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lightning_app/testing/config.py b/src/lightning_app/testing/config.py index e18ec0ebe75bd..2376e7032cd22 100644 --- a/src/lightning_app/testing/config.py +++ b/src/lightning_app/testing/config.py @@ -6,7 +6,7 @@ class _Config: id = os.getenv("LIGHTNING_USER_ID") key = os.getenv("LIGHTNING_API_KEY") - url = os.getenv("LIGHTNING_CLOUD_URL", "") + url = os.getenv("LIGHTNING_CLOUD_URL", "https://lightning.ai") api_key = os.getenv("LIGHTNING_API_KEY") username = os.getenv("LIGHTNING_USERNAME") video_location = os.getenv("VIDEO_LOCATION", "./artifacts/videos") diff --git a/tests/tests_examples_app/public/test_boring_app.py b/tests/tests_examples_app/public/test_boring_app.py index a97bccb93229b..a5177d0a18062 100644 --- a/tests/tests_examples_app/public/test_boring_app.py +++ b/tests/tests_examples_app/public/test_boring_app.py @@ -30,5 +30,5 @@ def check_hello_there(*_, **__): assert result.exit_code == 0 assert result.exception is None - assert any("--filepath=/content/.storage/boring_file.txt" in line for line in lines) + assert any("Received from root.dict.dst_w" in line for line in lines) print("Succeeded App!")