59
59
}
60
60
61
61
62
- def _get_url (task_id : str ) -> str :
62
+ def _get_url (task_id : Optional [ str ] = None , resource_id : Optional [ str ] = None , resource_type : Literal [ "task" , "group" ] = "task" ) -> str :
63
63
"""Get the URL for a task on our server."""
64
- return f"{ Env .current .website_endpoint } /workbench?taskId={ task_id } "
64
+ if task_id :
65
+ resource_id = task_id
65
66
67
+ elif not resource_id :
68
+ raise WebError (
69
+ "Required URL resource ID."
70
+ )
71
+
72
+ if resource_type == "task" :
73
+ return f"{ Env .current .website_endpoint } /workbench?taskId={ resource_id } "
74
+ elif resource_type == "group" :
75
+ return f"{ Env .current .website_endpoint } /workbench?groupId={ resource_id } "
66
76
67
77
def _get_folder_url (folder_id : str ) -> str :
68
78
"""Get the URL for a task folder on our server."""
@@ -167,7 +177,7 @@ def run(
167
177
Monitor progress of each of the running tasks.
168
178
"""
169
179
if isinstance (simulation , ComponentModelerType ):
170
- task_id = upload (
180
+ batch_id = upload (
171
181
simulation = simulation ,
172
182
task_name = task_name ,
173
183
folder_name = folder_name ,
@@ -179,20 +189,34 @@ def run(
179
189
solver_version = solver_version ,
180
190
reduce_simulation = reduce_simulation ,
181
191
)
182
- start (
183
- task_id ,
184
- solver_version = solver_version ,
185
- worker_group = worker_group ,
186
- pay_type = pay_type ,
187
- priority = priority ,
192
+ from tidy3d .plugins .smatrix .run import create_batch
193
+ batch = create_batch (
194
+ modeler = simulation ,
195
+ folder_name = folder_name ,
196
+ # parent_tasks=[task_id]
188
197
)
189
- monitor (task_id , verbose = verbose )
198
+ batch .run ()
199
+ from ..core .http_util import http
200
+ http .post (
201
+ f"tidy3d/projects/{ batch_id } /postprocess" ,
202
+ {
203
+ "batchType" : "RF_SWEEP"
204
+ },
205
+ )
206
+ # start(
207
+ # task_id,
208
+ # solver_version=solver_version,
209
+ # worker_group=worker_group,
210
+ # pay_type=pay_type,
211
+ # priority=priority,
212
+ # )
213
+ # monitor(task_id, verbose=verbose)
190
214
data = load (
191
215
task_id = task_id , path = path , verbose = verbose , progress_callback = progress_callback_download
192
216
)
193
- if isinstance (simulation , ModeSolver ):
194
- simulation ._patch_data (data = data )
195
- return data
217
+ # if isinstance(simulation, ModeSolver):
218
+ # simulation._patch_data(data=data)
219
+ # return data
196
220
else :
197
221
task_id = upload (
198
222
simulation = simulation ,
@@ -322,8 +346,8 @@ def upload(
322
346
)
323
347
if task_type in GUI_SUPPORTED_TASK_TYPES :
324
348
if isinstance (simulation , ComponentModelerType ):
325
- url = _get_url (task .batch_id )
326
- folder_url = _get_folder_url (task .batch_id )
349
+ url = _get_url (resource_id = task .group_id , resource_type = "group" )
350
+ folder_url = _get_folder_url (task .folder_id )
327
351
console .log (f"View task using web UI at [link={ url } ]'{ url } '[/link]." )
328
352
console .log (f"Task folder: [link={ folder_url } ]'{ task .folder_name } '[/link]." )
329
353
else :
@@ -335,23 +359,40 @@ def upload(
335
359
remote_sim_file = SIM_FILE_HDF5_GZ
336
360
if task_type == "MODE_SOLVER" :
337
361
remote_sim_file = MODE_FILE_HDF5_GZ
338
- elif task_type == "RF" :
362
+ elif isinstance ( simulation , ComponentModelerType ) :
339
363
remote_sim_file = MODELER_FILE_HDF5_GZ
340
364
341
- task .upload_simulation (
342
- stub = stub ,
343
- verbose = verbose ,
344
- task_type = task_type ,
345
- progress_callback = progress_callback ,
346
- remote_sim_file = remote_sim_file ,
347
- )
348
- estimate_cost (task_id = task .task_id , solver_version = solver_version , verbose = verbose )
365
+ if isinstance (simulation , ComponentModelerType ):
366
+ task .upload_simulation (
367
+ stub = stub ,
368
+ verbose = verbose ,
369
+ task_type = task_type ,
370
+ progress_callback = progress_callback ,
371
+ remote_sim_file = remote_sim_file ,
372
+ )
373
+ # TODO talk momchil
374
+ # estimate_cost(task_id=task.task_id, solver_version=solver_version, verbose=verbose)
375
+
376
+ task .validate_post_upload (parent_tasks = parent_tasks )
377
+
378
+ # log the url for the task in the web UI
379
+ log .debug (f"{ Env .current .website_endpoint } /folders/{ task .folder_id } /tasks/{ task .group_id } " )
380
+ return task .batch_id
381
+ else :
382
+ task .upload_simulation (
383
+ stub = stub ,
384
+ verbose = verbose ,
385
+ task_type = task_type ,
386
+ progress_callback = progress_callback ,
387
+ remote_sim_file = remote_sim_file ,
388
+ )
389
+ estimate_cost (task_id = task .task_id , solver_version = solver_version , verbose = verbose )
349
390
350
- task .validate_post_upload (parent_tasks = parent_tasks )
391
+ task .validate_post_upload (parent_tasks = parent_tasks )
351
392
352
- # log the url for the task in the web UI
353
- log .debug (f"{ Env .current .website_endpoint } /folders/{ task .folder_id } /tasks/{ task .task_id } " )
354
- return task .task_id
393
+ # log the url for the task in the web UI
394
+ log .debug (f"{ Env .current .website_endpoint } /folders/{ task .folder_id } /tasks/{ task .task_id } " )
395
+ return task .task_id
355
396
356
397
357
398
def get_reduced_simulation (simulation , reduce_simulation ):
0 commit comments