Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[App] Resolve race condition to move ui files #15398

Merged
merged 9 commits into from
Nov 11, 2022
3 changes: 3 additions & 0 deletions src/lightning_app/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion src/lightning_app/core/app.py
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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