Skip to content

Commit

Permalink
Dont try to update an instance that isnt running yet (#15998)
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanwharris authored Dec 9, 2022
1 parent 4bdc185 commit 5595166
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/lightning_app/components/serve/streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def run(self) -> None:
],
env=env,
)
self._process.wait()

def on_exit(self) -> None:
if self._process is not None:
Expand Down
7 changes: 2 additions & 5 deletions src/lightning_app/core/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 7 additions & 2 deletions src/lightning_app/utilities/app_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5595166

Please sign in to comment.