Skip to content

Commit

Permalink
[App] Resolve race condition to move ui files (#15398)
Browse files Browse the repository at this point in the history
  • Loading branch information
tchaton committed Nov 11, 2022
1 parent 75b5042 commit 2f0c039
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/lightning_app/CHANGELOG.md
Expand Up @@ -68,6 +68,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

Expand Down
4 changes: 3 additions & 1 deletion src/lightning_app/core/app.py
Expand Up @@ -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

Expand Down Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions src/lightning_app/runners/cloud.py
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/lightning_app/runners/multiprocess.py
Expand Up @@ -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)
Expand Down

0 comments on commit 2f0c039

Please sign in to comment.