Skip to content

Commit b1a2c1f

Browse files
committed
Passing taskType, cleanup and using MODAL_CM and TERMINAL_CM
1 parent 232e0c4 commit b1a2c1f

File tree

6 files changed

+20
-52
lines changed

6 files changed

+20
-52
lines changed

tidy3d/config/profiles.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
},
2222
"dev": {
2323
"web": {
24-
"api_endpoint": "https://tidy3d-api.dev-simulation.cloud",
25-
"website_endpoint": "https://tidy3d.dev-simulation.cloud",
24+
"api_endpoint": "https://tidy3d2-api.dev-simulation.cloud",
25+
"website_endpoint": "https://tidy3d2.dev-simulation.cloud",
2626
"s3_region": "us-east-1",
2727
}
2828
},

tidy3d/web/api/tidy3d_stub.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
EMESimulation: TaskType.EME,
4747
ModeSimulation: TaskType.MODE,
4848
VolumeMesher: TaskType.VOLUME_MESH,
49-
ModalComponentModeler: TaskType.COMPONENT_MODELER,
50-
TerminalComponentModeler: TaskType.TERMINAL_COMPONENT_MODELER,
49+
ModalComponentModeler: TaskType.MODAL_CM,
50+
TerminalComponentModeler: TaskType.TERMINAL_CM,
5151
}
5252

5353

tidy3d/web/api/webapi.py

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from tidy3d.config import config
2020
from tidy3d.exceptions import WebError
2121
from tidy3d.log import get_logging_console, log
22-
from tidy3d.plugins.smatrix.component_modelers.terminal import TerminalComponentModeler
2322
from tidy3d.web.api.states import (
2423
ALL_POST_VALIDATE_STATES,
2524
END_STATES,
@@ -59,7 +58,7 @@
5958
SIM_FILE_JSON = "simulation.json"
6059

6160
# not all solvers are supported yet in GUI
62-
GUI_SUPPORTED_TASK_TYPES = ["FDTD", "MODE_SOLVER", "HEAT", "RF"]
61+
GUI_SUPPORTED_TASK_TYPES = ["FDTD", "MODE_SOLVER", "HEAT", "TERMINAL_CM"]
6362

6463
# if a solver is in beta stage, cost is subject to change
6564
BETA_TASK_TYPES = ["HEAT", "EME", "HEAT_CHARGE", "VOLUME_MESH"]
@@ -228,7 +227,7 @@ def restore_simulation_if_cached(
228227
cached_workflow_type = entry.metadata.get("workflow_type")
229228
if cached_task_id is not None and cached_workflow_type is not None and verbose:
230229
console = get_logging_console()
231-
url, _ = _get_task_urls(cached_workflow_type, simulation, cached_task_id)
230+
url, _ = _get_task_urls(cached_workflow_type, cached_task_id)
232231
console.log(
233232
f"Loading simulation from local cache. View cached task using web UI at [link={url}]'{url}'[/link]."
234233
)
@@ -429,15 +428,12 @@ def run(
429428

430429
def _get_task_urls(
431430
task_type: str,
432-
simulation: WorkflowType,
433431
resource_id: str,
434432
folder_id: Optional[str] = None,
435433
group_id: Optional[str] = None,
436434
) -> tuple[str, Optional[str]]:
437435
"""Log task and folder links to the web UI."""
438-
if (task_type in ["RF", "COMPONENT_MODELER", "TERMINAL_COMPONENT_MODELER"]) and isinstance(
439-
simulation, TerminalComponentModeler
440-
):
436+
if task_type in ["RF", "TERMINAL_CM", "MODAL_CM"]:
441437
url = _get_url_rf(group_id or resource_id)
442438
else:
443439
url = _get_url(resource_id)
@@ -523,9 +519,6 @@ def upload(
523519
task_name = stub.get_default_task_name()
524520

525521
task_type = stub.get_type()
526-
# Component modeler compatibility: map to RF task type
527-
if task_type in ("COMPONENT_MODELER", "TERMINAL_COMPONENT_MODELER"):
528-
task_type = "RF"
529522

530523
task = WebTask.create(
531524
task_type,
@@ -537,23 +530,8 @@ def upload(
537530
"Gz",
538531
)
539532

540-
if task_type == "RF":
541-
# Prefer the group id if present in the creation response; avoid extra GET.
542-
group_id = getattr(task, "groupId", None) or getattr(task, "group_id", None)
543-
if not group_id:
544-
try:
545-
detail_task = SimulationTask.get(task.task_id, verbose=False)
546-
group_id = getattr(detail_task, "groupId", None) or getattr(
547-
detail_task, "group_id", None
548-
)
549-
except Exception:
550-
group_id = None
551-
# Prefer returning batch/group id for downstream batch endpoints
552-
task_id = getattr(task, "batchId", None) or getattr(task, "batch_id", None)
553-
resource_id = task_id or task.task_id
554-
else:
555-
group_id = None
556-
resource_id = task.task_id
533+
group_id = getattr(task, "groupId", None)
534+
resource_id = task.task_id
557535

558536
if verbose:
559537
console.log(
@@ -566,16 +544,14 @@ def upload(
566544
f"Cost of {solver_name} simulations is subject to change in the future."
567545
)
568546
if task_type in GUI_SUPPORTED_TASK_TYPES:
569-
url, folder_url = _get_task_urls(
570-
task_type, simulation, resource_id, task.folder_id, group_id
571-
)
547+
url, folder_url = _get_task_urls(task_type, resource_id, task.folder_id, group_id)
572548
console.log(f"View task using web UI at [link={url}]'{url}'[/link].")
573549
console.log(f"Task folder: [link={folder_url}]'{task.folder_name}'[/link].")
574550

575551
remote_sim_file = SIM_FILE_HDF5_GZ
576552
if task_type == "MODE_SOLVER":
577553
remote_sim_file = MODE_FILE_HDF5_GZ
578-
elif task_type == "RF":
554+
elif task_type in ["RF", "TERMINAL_CM", "MODAL_CM"]:
579555
remote_sim_file = MODELER_FILE_HDF5_GZ
580556

581557
task.upload_simulation(
@@ -981,9 +957,6 @@ def abort(task_id: TaskId) -> Optional[TaskInfo]:
981957
console.log(
982958
f"Task is aborting. View task using web UI at [link={url}]'{url}'[/link] to check the result."
983959
)
984-
if isinstance(task, BatchTask):
985-
detail = task.detail()
986-
return TaskInfo(**{"taskId": task_id, "taskType": "RF", **detail.dict()})
987960
return TaskInfo(
988961
**{"taskId": task_id, "taskType": getattr(task, "task_type", None), **task.dict()}
989962
)

tidy3d/web/core/task_core.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ def create(
199199

200200
folder = Folder.get(folder_name, create=True)
201201

202-
if task_type == "RF":
202+
if task_type in ["RF", "TERMINAL_CM", "MODAL_CM"]:
203203
payload = {
204204
"groupName": task_name,
205205
"folderId": folder.folder_id,
@@ -217,16 +217,7 @@ def create(
217217
"fileType": file_type,
218218
}
219219
resp = http.post(f"{projects_endpoint}/{folder.folder_id}/tasks", payload)
220-
# RF group creation may return group-level info without 'taskId'.
221-
# Use 'groupId' (or 'batchId' as fallback) as the resource id for subsequent uploads.
222-
if "taskId" not in resp and task_type == "RF":
223-
# Prefer using 'batchId' as the resource id for uploads (S3 STS expects a task-like id).
224-
if "batchId" in resp:
225-
resp["taskId"] = resp["batchId"]
226-
elif "groupId" in resp:
227-
resp["taskId"] = resp["groupId"]
228-
else:
229-
raise WebError("Missing resource ID for task creation. Contact customer support.")
220+
230221
return SimulationTask(**resp, taskType=task_type, folder_name=folder_name)
231222

232223
def get_url(self) -> str:
@@ -376,7 +367,7 @@ def delete(self, versions: bool = False) -> None:
376367
if not self.task_id:
377368
raise ValueError("Task id not found.")
378369

379-
task_details = self.detail()
370+
task_details = self.detail().dict()
380371

381372
if task_details and "groupId" in task_details:
382373
group_id = task_details["groupId"]

tidy3d/web/core/task_info.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ class TaskInfo(TaskBase):
128128
taskBlockInfo: TaskBlockInfo = None
129129
"""Blocking information for the task."""
130130

131+
version: str = None
132+
"""Version of the task."""
133+
131134

132135
class RunInfo(TaskBase):
133136
"""Information about the run of a task."""
@@ -257,6 +260,7 @@ class BatchDetail(TaskBase):
257260
tasks: list[BatchMember] = []
258261
validateErrors: dict = None
259262
taskType: str = "RF"
263+
version: str = None
260264

261265

262266
class AsyncJobDetail(TaskBase):

tidy3d/web/core/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class TaskType(str, Enum):
5656
EME = "EME"
5757
MODE = "MODE"
5858
VOLUME_MESH = "VOLUME_MESH"
59-
COMPONENT_MODELER = "COMPONENT_MODELER"
60-
TERMINAL_COMPONENT_MODELER = "TERMINAL_COMPONENT_MODELER"
59+
MODAL_CM = "MODAL_CM"
60+
TERMINAL_CM = "TERMINAL_CM"
6161

6262

6363
class PayType(str, Enum):

0 commit comments

Comments
 (0)