Skip to content

Commit 1f0e08a

Browse files
tchatonBorda
authored andcommitted
[App] Resolve race condition to move ui files (#15398)
(cherry picked from commit 2f0c039)
1 parent da0a402 commit 1f0e08a

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

src/lightning_app/CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
5555
- 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))
5656

5757

58+
- Fixed race condition to over-write the frontend with app infos ([#15398](https://github.com/Lightning-AI/lightning/pull/15398))
59+
60+
5861

5962
## [1.8.0] - 2022-11-01
6063

src/lightning_app/core/app.py

+3-1
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

+1
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

+2
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)