From 45d30a98a7679c4968a1d93d4c1b8106a3c5ccb3 Mon Sep 17 00:00:00 2001 From: Tyler Hughes Date: Thu, 30 May 2024 11:07:41 -0400 Subject: [PATCH] robust Batch.monitor --- CHANGELOG.md | 1 + tidy3d/web/api/container.py | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 30cf7c531..cab85bac9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - `ModeSolver.plot_field` correctly returning the plot axes. - Avoid error if non-positive refractive index used for integration resolution in adjoint. +- Make `Batch.monitor` robust if the run status is not found. ## [2.7.0rc2] - 2024-05-14 diff --git a/tidy3d/web/api/container.py b/tidy3d/web/api/container.py index d5bb45eef..61556083d 100644 --- a/tidy3d/web/api/container.py +++ b/tidy3d/web/api/container.py @@ -704,10 +704,11 @@ def pbar_description(task_name: str, status: str) -> str: for task_name, job in self.jobs.items(): status = job.status description = pbar_description(task_name, status) + completed = run_statuses.index(status) if status in run_statuses else 0 pbar = progress.add_task( description, total=len(run_statuses) - 1, - completed=run_statuses.index(status), + completed=completed, ) pbar_tasks[task_name] = pbar @@ -717,13 +718,10 @@ def pbar_description(task_name: str, status: str) -> str: status = job.status description = pbar_description(task_name, status) - # if a problem occurred, update progressbar completion to 100% - if status not in run_statuses: - completed = run_statuses.index("success") - else: + if status in run_statuses: completed = run_statuses.index(status) + progress.update(pbar, description=description, completed=completed) - progress.update(pbar, description=description, completed=completed) time.sleep(BATCH_MONITOR_PROGRESS_REFRESH_TIME) # set all to 100% completed (if error or diverge, will be red)