From bacfbae2cb13b176215a611e7f94b0dc2d51d39c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Thu, 15 Dec 2022 00:04:26 +0100 Subject: [PATCH] Load app before setting LIGHTNING_DISPATCHED (#16057) --- src/lightning_app/runners/runtime.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/lightning_app/runners/runtime.py b/src/lightning_app/runners/runtime.py index ab552f136fde0e..a30b78f9178a0a 100644 --- a/src/lightning_app/runners/runtime.py +++ b/src/lightning_app/runners/runtime.py @@ -55,9 +55,6 @@ def dispatch( from lightning_app.runners.runtime_type import RuntimeType from lightning_app.utilities.component import _set_flow_context - # Used to indicate Lightning has been dispatched - os.environ["LIGHTNING_DISPATCHED"] = "1" - _set_flow_context() runtime_type = RuntimeType(runtime_type) @@ -80,6 +77,8 @@ def dispatch( secrets=secrets, run_app_comment_commands=run_app_comment_commands, ) + # Used to indicate Lightning has been dispatched + os.environ["LIGHTNING_DISPATCHED"] = "1" # a cloud dispatcher will return the result while local # dispatchers will be running the app in the main process return runtime.dispatch(open_ui=open_ui, name=name, no_cache=no_cache, cluster_id=cluster_id)