diff --git a/src/lightning_app/CHANGELOG.md b/src/lightning_app/CHANGELOG.md index 7e97e8659c1ba..fa6bfc7667934 100644 --- a/src/lightning_app/CHANGELOG.md +++ b/src/lightning_app/CHANGELOG.md @@ -66,6 +66,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - 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)) +- Fixed race condition to over-write the frontend with app infos ([#15398](https://github.com/Lightning-AI/lightning/pull/15398)) + + ## [1.8.0] - 2022-11-01 diff --git a/src/lightning_app/core/app.py b/src/lightning_app/core/app.py index ef848cce54dba..17e91d565d6de 100644 --- a/src/lightning_app/core/app.py +++ b/src/lightning_app/core/app.py @@ -100,6 +100,7 @@ def __init__( """ self.root_path = root_path # when running behind a proxy + self.info = info from lightning_app.core.flow import _RootFlow @@ -168,9 +169,10 @@ def __init__( logger.debug(f"ENV: {os.environ}") + def _update_index_file(self): # update index.html, # this should happen once for all apps before the ui server starts running. - frontend.update_index_file(FRONTEND_DIR, info=info, root_path=root_path) + frontend.update_index_file(FRONTEND_DIR, info=self.info, root_path=self.root_path) if _should_dispatch_app(): os.environ["LIGHTNING_DISPATCHED"] = "1" diff --git a/src/lightning_app/runners/cloud.py b/src/lightning_app/runners/cloud.py index 81e9e10ebb14a..c551c1c76ec57 100644 --- a/src/lightning_app/runners/cloud.py +++ b/src/lightning_app/runners/cloud.py @@ -99,6 +99,7 @@ def dispatch( app_config = AppConfig.load_from_file(config_file) if config_file else AppConfig() root = config_file.parent if config_file else Path(self.entrypoint_file).absolute().parent cleanup_handle = _prepare_lightning_wheels_and_requirements(root) + self.app._update_index_file() repo = LocalSourceCodeDir(path=root) self._check_uploaded_folder(root, repo) requirements_file = root / "requirements.txt" diff --git a/src/lightning_app/runners/multiprocess.py b/src/lightning_app/runners/multiprocess.py index 1bc8c7b5cf178..8abd0a443ac32 100644 --- a/src/lightning_app/runners/multiprocess.py +++ b/src/lightning_app/runners/multiprocess.py @@ -30,9 +30,11 @@ def dispatch(self, *args: Any, on_before_run: Optional[Callable] = None, **kwarg """Method to dispatch and run the LightningApp.""" try: _set_flow_context() + self.app.backend = self.backend self.backend._prepare_queues(self.app) self.backend.resolve_url(self.app, "http://127.0.0.1") + self.app._update_index_file() # set env variables os.environ.update(self.env_vars)