Skip to content

Commit ab7d945

Browse files
committed
end of copilot changes
1 parent 658f706 commit ab7d945

3 files changed

Lines changed: 9 additions & 52 deletions

File tree

tidy3d/web/api/states.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,13 @@
3636

3737
END_STATES = ERROR_STATES | COMPLETED_STATES
3838

39-
POST_VALIDATE_STATES = {
40-
"validate_success",
41-
"validate_warn",
42-
}
39+
POST_VALIDATE_STATES = {"validate_success", "validate_warn"}
4340

4441
RUNNING_STATES = (
4542
PRE_VALIDATE_STATES | POST_VALIDATE_STATES | {"running"} | POST_RUN_STATES | COMPLETED_STATES
4643
)
4744

48-
ALL_POST_VALIDATE_STATES = POST_VALIDATE_STATES | {"running"} | POST_RUN_STATES | COMPLETED_STATES
45+
ALL_POST_VALIDATE_STATES = POST_VALIDATE_STATES | {"running"} | POST_RUN_STATES | END_STATES
4946

5047
VALID_PROGRESS_STATES = RUNNING_STATES | PRE_ERROR_STATES
5148

tidy3d/web/api/webapi.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,9 @@ def get_info(task_id: TaskId, verbose: bool = True) -> TaskInfo | BatchDetail:
669669
task = TaskFactory.get(task_id, verbose=verbose)
670670
if not task:
671671
raise ValueError("Task not found.")
672-
info = TaskFactory.normalize_info(task)
673-
return info
672+
if isinstance(task, BatchTask):
673+
return task.detail()
674+
return TaskInfo(**{"taskId": task.task_id, **task.dict()})
674675

675676

676677
@wait_for_connection
@@ -747,7 +748,7 @@ def _get_batch_detail_handle_error_status(batch: BatchTask) -> BatchDetail:
747748
detail = batch.detail()
748749
status = detail.status.lower()
749750
if status in ERROR_STATES:
750-
raise _batch_detail_error(batch.id)
751+
raise _batch_detail_error(batch.task_id)
751752
return detail
752753

753754

@@ -1515,6 +1516,7 @@ def estimate_cost(
15151516
if status in ERROR_STATES:
15161517
raise _batch_detail_error(resource_id=task_id)
15171518
raise WebError("Could not get estimated cost!")
1519+
15181520
# simulation path
15191521
task.estimate_cost(solver_version=solver_version)
15201522
task_info = get_info(task_id)
@@ -1724,3 +1726,4 @@ def test() -> None:
17241726
f"For details, check the instructions at {url}."
17251727
)
17261728
raise WebError(msg) from e
1729+
raise WebError(msg) from e

tidy3d/web/core/task_core.py

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
import requests
1313
from botocore.exceptions import ClientError
14-
from pydantic.v1 import BaseModel, Extra, Field, parse_obj_as
14+
from pydantic.v1 import Extra, Field, parse_obj_as
1515

1616
import tidy3d as td
1717
from tidy3d.config import config
@@ -143,20 +143,6 @@ def list_tasks(self, projects_endpoint: str = "tidy3d/projects") -> list[Tidy3DR
143143
)
144144

145145

146-
class WebTaskInfo(BaseModel):
147-
"""Normalized task/batch info."""
148-
149-
taskId: str
150-
taskType: str
151-
status: Optional[str] = None
152-
folderId: Optional[str] = None
153-
folderName: Optional[str] = None
154-
estFlexUnit: Optional[float] = None
155-
realFlexUnit: Optional[float] = None
156-
metadataStatus: Optional[str] = None
157-
createdAt: Optional[datetime] = None
158-
159-
160146
class WebTask(ResourceLifecycle, Submittable, extra=Extra.allow):
161147
"""Interface for managing the running a task on the server."""
162148

@@ -947,39 +933,10 @@ def get(cls, task_id: str, verbose: bool = True) -> WebTask:
947933
if kind == "simulation":
948934
task = SimulationTask.get(task_id, verbose=verbose)
949935
return task
950-
# probe batch non-throwing
951936
if WebTask.is_batch(task_id):
952937
cls.register(task_id, "batch")
953938
return BatchTask(task_id)
954939
task = SimulationTask.get(task_id, verbose=verbose)
955940
if task:
956941
cls.register(task_id, "simulation")
957942
return task
958-
959-
@classmethod
960-
def normalize_info(cls, task: WebTask) -> WebTaskInfo:
961-
if isinstance(task, BatchTask):
962-
detail = task.detail()
963-
return WebTaskInfo(
964-
taskId=task.task_id,
965-
taskType="RF",
966-
status=detail.status,
967-
folderId=getattr(detail, "folderId", None),
968-
folderName=getattr(detail, "folderName", None),
969-
estFlexUnit=getattr(detail, "estFlexUnit", None),
970-
realFlexUnit=getattr(detail, "realFlexUnit", None),
971-
metadataStatus=getattr(detail, "metadataStatus", None),
972-
createdAt=None,
973-
)
974-
# SimulationTask
975-
return WebTaskInfo(
976-
taskId=task.task_id,
977-
taskType=getattr(task, "task_type", None),
978-
status=getattr(task, "status", None),
979-
folderId=getattr(task, "folder_id", None),
980-
folderName=getattr(task, "folder_name", None),
981-
estFlexUnit=getattr(task, "estFlexUnit", None),
982-
realFlexUnit=getattr(task, "real_flex_unit", None),
983-
metadataStatus=getattr(task, "metadataStatus", None),
984-
createdAt=getattr(task, "created_at", None),
985-
)

0 commit comments

Comments
 (0)