From 326b4cb51f352be8994e28ec9b2d48737da5ceb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Fri, 25 Nov 2022 19:24:04 +0100 Subject: [PATCH 1/2] Print the app ID as early as possible --- src/lightning_app/testing/testing.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/lightning_app/testing/testing.py b/src/lightning_app/testing/testing.py index fb087a2d62b71..5a99f3ae20c28 100644 --- a/src/lightning_app/testing/testing.py +++ b/src/lightning_app/testing/testing.py @@ -383,12 +383,12 @@ def run_app_in_cloud( ).lightningapps if app.name == name ] - if not lit_apps: return True - assert len(lit_apps) == 1 - app_id = lit_apps[0].id + app = lit_apps[0] + app_id = app.id + print(f"The Lightning App ID is: {app.id}") # useful for Grafana if debug: process = Process(target=_print_logs, kwargs={"app_id": app_id}) @@ -404,24 +404,13 @@ def run_app_in_cloud( except (playwright._impl._api_types.Error, playwright._impl._api_types.TimeoutError): pass - lit_apps = [ - app - for app in client.lightningapp_instance_service_list_lightningapp_instances( - project_id=project.project_id - ).lightningapps - if app.name == name - ] - - app_url = lit_apps[0].status.url - + app_url = app.status.url while True: sleep(1) resp = requests.get(app_url + "/openapi.json") if resp.status_code == 200: break - print(f"The Lightning Id Name : [bold magenta]{app_id}[/bold magenta]") - logs_api_client = _LightningLogsSocketAPI(client.api_client) def fetch_logs(component_names: Optional[List[str]] = None) -> Generator: From 8ae7543a1a8598f4da4bdeeb611a8a4fcd995b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mochol=C3=AD?= Date: Sat, 26 Nov 2022 05:57:23 +0100 Subject: [PATCH 2/2] Am I crazy? --- src/lightning_app/testing/testing.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/lightning_app/testing/testing.py b/src/lightning_app/testing/testing.py index 5a99f3ae20c28..2ce426ecf109e 100644 --- a/src/lightning_app/testing/testing.py +++ b/src/lightning_app/testing/testing.py @@ -404,6 +404,15 @@ def run_app_in_cloud( except (playwright._impl._api_types.Error, playwright._impl._api_types.TimeoutError): pass + # TODO: is re-creating this redundant? + lit_apps = [ + app + for app in client.lightningapp_instance_service_list_lightningapp_instances( + project_id=project.project_id + ).lightningapps + if app.name == name + ] + app = lit_apps[0] app_url = app.status.url while True: sleep(1)