Skip to content

Commit d380ce7

Browse files
Update batch web status names (#2756)
* Update web status * Minor fixs * Final typo
1 parent bd88ce0 commit d380ce7

File tree

3 files changed

+59
-60
lines changed

3 files changed

+59
-60
lines changed

tidy3d/web/api/webapi.py

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def dict_to_bullet_list(data_dict: dict) -> str:
498498
check_resp = batch.check(solver_version=solver_version, batch_type="RF_SWEEP")
499499
detail = batch.wait_for_validate(batch_type="RF_SWEEP")
500500
status = detail.status
501-
if status not in ("Validate_Success", "Validate_Warn"):
501+
if status not in ("validate_success", "validate_warn"):
502502
# Surface server-provided reason if available
503503
reason = None
504504
try:
@@ -823,7 +823,7 @@ def _download_cm() -> bool:
823823
total = resp.totalTask or 0
824824
post_succ = resp.postprocessSuccess or 0
825825
status = resp.status
826-
if status in {"Run_Failed", "Run_Diverged", "Blocked", "Aborted", "Abort"}:
826+
if status in {"error", "diverged", "blocked", "aborted", "aborting"}:
827827
raise WebError(
828828
f"Batch task {task_id} failed during postprocess: {status}"
829829
) from None
@@ -989,19 +989,19 @@ def _monitor_modeler_batch(batch_id: str, verbose: bool = True, max_detail_tasks
989989
console = get_logging_console() if verbose else None
990990

991991
def _status_to_stage(status: str) -> tuple[str, int]:
992-
if status in ("Created",):
993-
return ("Created", 0)
994-
if status in ("Preprocess",):
995-
return ("Preprocess", 1)
996-
if status in ("Validating",):
997-
return ("Validating", 2)
998-
if status in ("Validate_Success", "Validate_Warn"):
992+
if status in ("draft",):
993+
return ("draft", 0)
994+
if status in ("preprocess",):
995+
return ("preprocess", 1)
996+
if status in ("validating",):
997+
return ("validating", 2)
998+
if status in ("validate_success", "validate_warn"):
999999
return ("Validate", 3)
1000-
if status in ("Running",):
1001-
return ("Running", 4)
1002-
if status in ("Postprocess",):
1003-
return ("Postprocess", 5)
1004-
if status in ("Run_Success",):
1000+
if status in ("running",):
1001+
return ("running", 4)
1002+
if status in ("postprocess",):
1003+
return ("postprocess", 5)
1004+
if status in ("run_success",):
10051005
return ("Success", 6)
10061006
return (status, 6)
10071007

@@ -1025,23 +1025,23 @@ def _status_to_stage(status: str) -> tuple[str, int]:
10251025
with Progress(*progress_columns, console=console, transient=False) as progress:
10261026
p_validate = progress.add_task("Validate", total=1.0)
10271027
p_run = progress.add_task("Run", total=1.0)
1028-
p_post = progress.add_task("Postprocess", total=1.0)
1028+
p_post = progress.add_task("postprocess", total=1.0)
10291029

10301030
task_bars = {}
10311031
total_task = detail.totalTask or 0
10321032
if total_task and total_task <= max_detail_tasks:
10331033
run_statuses = [
1034-
"Created",
1035-
"Preprocess",
1036-
"Validating",
1034+
"draft",
1035+
"preprocess",
1036+
"validating",
10371037
"Validate",
1038-
"Running",
1039-
"Postprocess",
1038+
"running",
1039+
"postprocess",
10401040
"Success",
10411041
]
10421042
for t in detail.tasks or []:
10431043
tname = t.taskName or t.taskId
1044-
status = t.status or "Created"
1044+
status = t.status or "draft"
10451045
_, idx = _status_to_stage(status)
10461046
pbar = progress.add_task(
10471047
f"{tname}",
@@ -1051,12 +1051,12 @@ def _status_to_stage(status: str) -> tuple[str, int]:
10511051
task_bars[tname] = pbar
10521052

10531053
terminal_errors = {
1054-
"Validate_Failed",
1055-
"Run_Failed",
1056-
"Run_Diverged",
1057-
"Blocked",
1058-
"Abort",
1059-
"Aborted",
1054+
"validate_fail",
1055+
"error",
1056+
"diverged",
1057+
"blocked",
1058+
"aborting",
1059+
"aborted",
10601060
}
10611061

10621062
postprocess_triggered = False
@@ -1085,14 +1085,14 @@ def _status_to_stage(status: str) -> tuple[str, int]:
10851085
if task_bars:
10861086
for t in detail.tasks or []:
10871087
tname = t.taskName or t.taskId
1088-
status = t.status or "Created"
1088+
status = t.status or "draft"
10891089
_, idx = _status_to_stage(status)
10901090
pbar = task_bars.get(tname)
10911091
if pbar is not None:
10921092
progress.update(pbar, completed=min(idx, 6), refresh=False)
10931093

10941094
# If run succeeded but postprocess not yet complete, trigger it and keep waiting
1095-
if status in ("Run_Success", "Postprocess") or r >= total:
1095+
if status in ("run_success", "postprocess") or r >= total:
10961096
if not postprocess_triggered:
10971097
# Kick off postprocess once
10981098
try:
@@ -1113,12 +1113,12 @@ def _status_to_stage(status: str) -> tuple[str, int]:
11131113
time.sleep(REFRESH_TIME)
11141114
else:
11151115
terminal_errors = {
1116-
"Validate_Failed",
1117-
"Run_Failed",
1118-
"Run_Diverged",
1119-
"Blocked",
1120-
"Abort",
1121-
"Aborted",
1116+
"validate_fail",
1117+
"error",
1118+
"diverged",
1119+
"blocked",
1120+
"aborting",
1121+
"aborted",
11221122
}
11231123
postprocess_triggered = False
11241124
while True:
@@ -1127,7 +1127,7 @@ def _status_to_stage(status: str) -> tuple[str, int]:
11271127
total = d.totalTask or 0
11281128
p = d.postprocessSuccess or 0
11291129
r = d.runSuccess or 0
1130-
if (s in ("Run_Success", "Postprocess") or r >= total) and total:
1130+
if (s in ("run_success", "postprocess") or r >= total) and total:
11311131
if p < total and not postprocess_triggered:
11321132
try:
11331133
BatchTask(batch_id).postprocess(batch_type="RF_SWEEP")

tidy3d/web/core/task_core.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ def get_error_json(self, to_file: str, verbose: bool = True) -> pathlib.Path:
713713
)
714714

715715
def abort(self):
716-
"""Abort current task from server."""
716+
"""Aborting current task from server."""
717717
if not self.task_id:
718718
raise ValueError("Task id not found.")
719719
return http.put(
@@ -839,9 +839,9 @@ def wait_for_validate(
839839
while True:
840840
d = self.detail(batch_type=batch_type)
841841
status = d.status
842-
if status in ("Validate_Success", "Validate_Warn", "Validate_Failed"):
842+
if status in ("validate_success", "validate_warn", "validate_fail"):
843843
return d
844-
if status in ("Blocked", "Abort", "Aborted"):
844+
if status in ("blocked", "aborting", "aborted"):
845845
return d
846846
if timeout is not None and (datetime.now().timestamp() - start) > timeout:
847847
return d
@@ -853,12 +853,12 @@ def wait_for_run(self, timeout: Optional[float] = None, batch_type: str = "") ->
853853
d = self.detail(batch_type=batch_type)
854854
status = d.status
855855
if status in (
856-
"Run_Success",
857-
"Run_Failed",
858-
"Run_Diverged",
859-
"Blocked",
860-
"Abort",
861-
"Aborted",
856+
"run_success",
857+
"run_failed",
858+
"diverged",
859+
"blocked",
860+
"aborting",
861+
"aborted",
862862
):
863863
return d
864864
if timeout is not None and (datetime.now().timestamp() - start) > timeout:

tidy3d/web/core/task_info.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,20 @@ def display(self):
173173

174174

175175
class BatchStatus(str, Enum):
176-
Created = "Created"
177-
Preprocess = "Preprocess"
178-
Validating = "Validating"
179-
Validate_Success = "Validate_Success"
180-
Validate_Warn = "Validate_Warn"
181-
Validate_Failed = "Validate_Failed"
182-
Blocked = "Blocked"
183-
Running = "Running"
184-
Aborting = "Aborting"
185-
Run_Success = "Run_Success"
186-
Postprocess = "Postprocess"
187-
Run_Failed = "Run_Failed"
188-
Run_Diverged = "Run_Diverged"
189-
Abort = "Abort"
190-
Aborted = "Aborted"
176+
draft = "draft"
177+
preprocess = "preprocess"
178+
validating = "validating"
179+
validate_success = "validate_success"
180+
validate_warn = "validate_warn"
181+
validate_fail = "validate_fail"
182+
blocked = "blocked"
183+
running = "running"
184+
aborting = "aborting"
185+
run_success = "run_success"
186+
postprocess = "postprocess"
187+
run_failed = "run_failed"
188+
diverged = "diverged"
189+
aborted = "aborted"
191190

192191

193192
class BatchTaskBlockInfo(TaskBlockInfo):

0 commit comments

Comments
 (0)