Skip to content

Commit 00487c1

Browse files
fix: rf-migraton propagate batch-kwargs
1 parent 2e56ace commit 00487c1

File tree

2 files changed

+4
-33
lines changed

2 files changed

+4
-33
lines changed

tests/test_plugins/smatrix/test_run_functions.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ def test_create_batch(monkeypatch, tmp_path):
9999
result_batch = create_batch(modeler=dummy_modeler, path_dir=str(tmp_path))
100100
mock_batch_class.assert_called_once_with(
101101
simulations=dummy_modeler.sim_dict,
102-
parent_tasks=None,
103-
group_ids=None,
104102
)
105103
mock_batch_instance.to_file.assert_called_once_with(os.path.join(str(tmp_path), "batch.hdf5"))
106104
assert result_batch == mock_batch_instance
@@ -110,25 +108,16 @@ def test_create_batch(monkeypatch, tmp_path):
110108
mock_batch_instance.to_file.reset_mock()
111109

112110
# Test with parent_batch_id and group_id
113-
parent_id = "parent123"
114-
group_id = "groupABC"
115111
file_name = "custom_batch.hdf5"
116112
result_batch = create_batch(
117113
modeler=dummy_modeler,
118114
path_dir=str(tmp_path),
119-
parent_batch_id=parent_id,
120-
group_id=group_id,
121115
file_name=file_name,
122116
some_kwarg="value",
123117
)
124118

125-
expected_parent_tasks = dict.fromkeys(dummy_modeler.sim_dict.keys(), (parent_id,))
126-
expected_group_ids = dict.fromkeys(dummy_modeler.sim_dict.keys(), (group_id,))
127-
128119
mock_batch_class.assert_called_once_with(
129120
simulations=dummy_modeler.sim_dict,
130-
parent_tasks=expected_parent_tasks,
131-
group_ids=expected_group_ids,
132121
some_kwarg="value",
133122
)
134123
mock_batch_instance.to_file.assert_called_once_with(os.path.join(str(tmp_path), file_name))

tidy3d/plugins/smatrix/run.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import json
44
import os
5-
from typing import Optional
65

76
from tidy3d.components.base import Tidy3dBaseModel
87
from tidy3d.plugins.smatrix.component_modelers.modal import ModalComponentModeler
@@ -250,8 +249,6 @@ def compose_modeler_data_from_batch_data(
250249
def create_batch(
251250
modeler: ComponentModelerType,
252251
path_dir: str = DEFAULT_DATA_DIR,
253-
parent_batch_id: Optional[str] = None,
254-
group_id: Optional[str] = None,
255252
file_name: str = "batch.hdf5",
256253
**kwargs,
257254
) -> Batch:
@@ -279,33 +276,16 @@ def create_batch(
279276
"""
280277
filepath = os.path.join(path_dir, file_name)
281278

282-
if parent_batch_id is not None:
283-
parent_task_dict = {}
284-
for key in modeler.sim_dict.keys():
285-
parent_task_dict[key] = (parent_batch_id,)
286-
else:
287-
parent_task_dict = None
288-
289-
if group_id is not None:
290-
group_id_dict = {}
291-
for key in modeler.sim_dict.keys():
292-
group_id_dict[key] = (group_id,)
293-
else:
294-
group_id_dict = None
295-
296279
batch = Batch(
297280
simulations=modeler.sim_dict,
298-
parent_tasks=parent_task_dict,
299-
group_ids=group_id_dict,
300281
**kwargs,
301282
)
302283
batch.to_file(filepath)
303284
return batch
304285

305286

306287
def run(
307-
modeler: ComponentModelerType,
308-
path_dir: str = DEFAULT_DATA_DIR,
288+
modeler: ComponentModelerType, path_dir: str = DEFAULT_DATA_DIR, **kwargs
309289
) -> ComponentModelerDataType:
310290
"""Execute the full simulation workflow for a given component modeler.
311291
@@ -320,14 +300,16 @@ def run(
320300
The component modeler defining the simulations to be run.
321301
path_dir : str, optional
322302
The directory where the batch file will be saved. Defaults to ".".
303+
**kwargs
304+
Extra keyword arguments propagated to the Batch creation.
323305
324306
Returns
325307
-------
326308
ComponentModelerDataType
327309
An object containing the processed simulation data, ready for
328310
S-parameter extraction and analysis.
329311
"""
330-
batch = create_batch(modeler=modeler, path_dir=path_dir)
312+
batch = create_batch(modeler=modeler, path_dir=path_dir, **kwargs)
331313
batch_data = batch.run()
332314
modeler_data = compose_modeler_data_from_batch_data(modeler=modeler, batch_data=batch_data)
333315
return modeler_data

0 commit comments

Comments
 (0)