Skip to content

Commit 2f0c039

Browse files
authored
[App] Resolve race condition to move ui files (#15398)
1 parent 75b5042 commit 2f0c039

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

src/lightning_app/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
6868
- Fixed an issue with the `lightning` CLI taking a long time to error out when the cloud is not reachable ([#15412](https://github.com/Lightning-AI/lightning/pull/15412))
6969

7070

71+
- Fixed race condition to over-write the frontend with app infos ([#15398](https://github.com/Lightning-AI/lightning/pull/15398))
72+
73+
7174

7275
## [1.8.0] - 2022-11-01
7376

src/lightning_app/core/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def __init__(
100100
"""
101101

102102
self.root_path = root_path # when running behind a proxy
103+
self.info = info
103104

104105
from lightning_app.core.flow import _RootFlow
105106

@@ -168,9 +169,10 @@ def __init__(
168169

169170
logger.debug(f"ENV: {os.environ}")
170171

172+
def _update_index_file(self):
171173
# update index.html,
172174
# this should happen once for all apps before the ui server starts running.
173-
frontend.update_index_file(FRONTEND_DIR, info=info, root_path=root_path)
175+
frontend.update_index_file(FRONTEND_DIR, info=self.info, root_path=self.root_path)
174176

175177
if _should_dispatch_app():
176178
os.environ["LIGHTNING_DISPATCHED"] = "1"

src/lightning_app/runners/cloud.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ def dispatch(
9999
app_config = AppConfig.load_from_file(config_file) if config_file else AppConfig()
100100
root = config_file.parent if config_file else Path(self.entrypoint_file).absolute().parent
101101
cleanup_handle = _prepare_lightning_wheels_and_requirements(root)
102+
self.app._update_index_file()
102103
repo = LocalSourceCodeDir(path=root)
103104
self._check_uploaded_folder(root, repo)
104105
requirements_file = root / "requirements.txt"

src/lightning_app/runners/multiprocess.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ def dispatch(self, *args: Any, on_before_run: Optional[Callable] = None, **kwarg
3030
"""Method to dispatch and run the LightningApp."""
3131
try:
3232
_set_flow_context()
33+
3334
self.app.backend = self.backend
3435
self.backend._prepare_queues(self.app)
3536
self.backend.resolve_url(self.app, "http://127.0.0.1")
37+
self.app._update_index_file()
3638

3739
# set env variables
3840
os.environ.update(self.env_vars)

0 commit comments

Comments
 (0)