Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 36 additions & 36 deletions tidy3d/web/api/webapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def dict_to_bullet_list(data_dict: dict) -> str:
check_resp = batch.check(solver_version=solver_version, batch_type="RF_SWEEP")
detail = batch.wait_for_validate(batch_type="RF_SWEEP")
status = detail.status
if status not in ("validate_success", "validate_warn"):
if status not in ("Validate_Success", "Validate_Warn"):
# Surface server-provided reason if available
reason = None
try:
Expand Down Expand Up @@ -823,7 +823,7 @@ def _download_cm() -> bool:
total = resp.totalTask or 0
post_succ = resp.postprocessSuccess or 0
status = resp.status
if status in {"error", "diverged", "blocked", "aborted", "aborting"}:
if status in {"Run_Failed", "Run_Diverged", "Blocked", "Aborted", "Abort"}:
raise WebError(
f"Batch task {task_id} failed during postprocess: {status}"
) from None
Expand Down Expand Up @@ -989,19 +989,19 @@ def _monitor_modeler_batch(batch_id: str, verbose: bool = True, max_detail_tasks
console = get_logging_console() if verbose else None

def _status_to_stage(status: str) -> tuple[str, int]:
if status in ("draft",):
return ("draft", 0)
if status in ("preprocess",):
return ("preprocess", 1)
if status in ("validating",):
return ("validating", 2)
if status in ("validate_success", "validate_warn"):
if status in ("Created",):
return ("Created", 0)
if status in ("Preprocess",):
return ("Preprocess", 1)
if status in ("Validating",):
return ("Validating", 2)
if status in ("Validate_Success", "Validate_Warn"):
return ("Validate", 3)
if status in ("running",):
return ("running", 4)
if status in ("postprocess",):
return ("postprocess", 5)
if status in ("run_success",):
if status in ("Running",):
return ("Running", 4)
if status in ("Postprocess",):
return ("Postprocess", 5)
if status in ("Run_Success",):
return ("Success", 6)
return (status, 6)

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

task_bars = {}
total_task = detail.totalTask or 0
if total_task and total_task <= max_detail_tasks:
run_statuses = [
"draft",
"preprocess",
"validating",
"Created",
"Preprocess",
"Validating",
"Validate",
"running",
"postprocess",
"Running",
"Postprocess",
"Success",
]
for t in detail.tasks or []:
tname = t.taskName or t.taskId
status = t.status or "draft"
status = t.status or "Created"
_, idx = _status_to_stage(status)
pbar = progress.add_task(
f"{tname}",
Expand All @@ -1051,12 +1051,12 @@ def _status_to_stage(status: str) -> tuple[str, int]:
task_bars[tname] = pbar

terminal_errors = {
"validate_fail",
"error",
"diverged",
"blocked",
"aborting",
"aborted",
"Validate_Failed",
"Run_Failed",
"Run_Diverged",
"Blocked",
"Abort",
"Aborted",
}

postprocess_triggered = False
Expand Down Expand Up @@ -1085,14 +1085,14 @@ def _status_to_stage(status: str) -> tuple[str, int]:
if task_bars:
for t in detail.tasks or []:
tname = t.taskName or t.taskId
status = t.status or "draft"
status = t.status or "Created"
_, idx = _status_to_stage(status)
pbar = task_bars.get(tname)
if pbar is not None:
progress.update(pbar, completed=min(idx, 6), refresh=False)

# If run succeeded but postprocess not yet complete, trigger it and keep waiting
if status in ("run_success", "postprocess") or r >= total:
if status in ("Run_Success", "Postprocess") or r >= total:
if not postprocess_triggered:
# Kick off postprocess once
try:
Expand All @@ -1113,12 +1113,12 @@ def _status_to_stage(status: str) -> tuple[str, int]:
time.sleep(REFRESH_TIME)
else:
terminal_errors = {
"validate_fail",
"error",
"diverged",
"blocked",
"aborting",
"aborted",
"Validate_Failed",
"Run_Failed",
"Run_Diverged",
"Blocked",
"Abort",
"Aborted",
}
postprocess_triggered = False
while True:
Expand All @@ -1127,7 +1127,7 @@ def _status_to_stage(status: str) -> tuple[str, int]:
total = d.totalTask or 0
p = d.postprocessSuccess or 0
r = d.runSuccess or 0
if (s in ("run_success", "postprocess") or r >= total) and total:
if (s in ("Run_Success", "Postprocess") or r >= total) and total:
if p < total and not postprocess_triggered:
try:
BatchTask(batch_id).postprocess(batch_type="RF_SWEEP")
Expand Down
18 changes: 9 additions & 9 deletions tidy3d/web/core/task_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ def get_error_json(self, to_file: str, verbose: bool = True) -> pathlib.Path:
)

def abort(self):
"""Aborting current task from server."""
"""Abort current task from server."""
if not self.task_id:
raise ValueError("Task id not found.")
return http.put(
Expand Down Expand Up @@ -839,9 +839,9 @@ def wait_for_validate(
while True:
d = self.detail(batch_type=batch_type)
status = d.status
if status in ("validate_success", "validate_warn", "validate_fail"):
if status in ("Validate_Success", "Validate_Warn", "Validate_Failed"):
return d
if status in ("blocked", "aborting", "aborted"):
if status in ("Blocked", "Abort", "Aborted"):
return d
if timeout is not None and (datetime.now().timestamp() - start) > timeout:
return d
Expand All @@ -853,12 +853,12 @@ def wait_for_run(self, timeout: Optional[float] = None, batch_type: str = "") ->
d = self.detail(batch_type=batch_type)
status = d.status
if status in (
"run_success",
"run_failed",
"diverged",
"blocked",
"aborting",
"aborted",
"Run_Success",
"Run_Failed",
"Run_Diverged",
"Blocked",
"Abort",
"Aborted",
):
return d
if timeout is not None and (datetime.now().timestamp() - start) > timeout:
Expand Down
29 changes: 15 additions & 14 deletions tidy3d/web/core/task_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,21 @@ def display(self):


class BatchStatus(str, Enum):
draft = "draft"
preprocess = "preprocess"
validating = "validating"
validate_success = "validate_success"
validate_warn = "validate_warn"
validate_fail = "validate_fail"
blocked = "blocked"
running = "running"
aborting = "aborting"
run_success = "run_success"
postprocess = "postprocess"
run_failed = "run_failed"
diverged = "diverged"
aborted = "aborted"
Created = "Created"
Preprocess = "Preprocess"
Validating = "Validating"
Validate_Success = "Validate_Success"
Validate_Warn = "Validate_Warn"
Validate_Failed = "Validate_Failed"
Blocked = "Blocked"
Running = "Running"
Aborting = "Aborting"
Run_Success = "Run_Success"
Postprocess = "Postprocess"
Run_Failed = "Run_Failed"
Run_Diverged = "Run_Diverged"
Abort = "Abort"
Aborted = "Aborted"


class BatchTaskBlockInfo(TaskBlockInfo):
Expand Down