tidy3d.web.api.container.Batch#
- class Batch[source]#
Bases:
WebContainer
Interface for submitting several
Simulation
objects to sever.- Parameters:
simulations (Mapping[str, Annotated[Union[tidy3d.components.simulation.Simulation, tidy3d.components.heat.simulation.HeatSimulation], FieldInfo(default=PydanticUndefined, discriminator='type', extra={})]]) β Mapping of task names to Simulations to run as a batch.
folder_name (str = default) β Name of folder to store member of each batch on web UI.
verbose (bool = True) β Whether to print info messages and progressbars.
solver_version (Optional[str] = None) β callback_url : Optional[str] = None Http PUT url to receive simulation finish event. The body content is a json file with fields
{'id', 'status', 'name', 'workUnit', 'solverVersion'}
.simulation_type (str = tidy3d) β Type of each simulation in the batch, used internally only.
parent_tasks (Optional[Mapping[str, Tuple[str, ...]]] = None) β Collection of parent task ids for each job in batch, used internally only.
jobs (Optional[Mapping[str, Job]] = None) β Mapping of task names to individual Job object for each task in the batch. Set by
Batch.upload
, leave as None.
Notes
Commonly one needs to submit a batch of
Simulation
. The built-inBatch
object is the best way to upload, start, monitor, and load a series of tasks. The batch object is like aJob
, but stores task metadata for a series of simulations.See also
tidy3d.web.api.webapi.run_async()
Submits a set of
Simulation
objects to server, starts running, monitors progress, downloads, and loads results as aBatchData
object.Job
:Interface for managing the running of a Simulation on server.
- Notebooks
Attributes
Methods
delete
()Delete server-side data associated with each task in the batch.
download
([path_dir])Download results of each task.
estimate_cost
([verbose])Compute the maximum FlexCredit charge for a given
Batch
.get_info
()Get information about each task in the
Batch
.get information about a each of the tasks in the
Batch
.load
([path_dir])Download results and load them into
BatchData
object.monitor
()Monitor progress of each of the running tasks.
real_cost
([verbose])Get the sum of billed costs for each task associated with this batch.
run
([path_dir])Upload and run each simulation in
Batch
.start
()Start running all tasks in the
Batch
.- simulations#
- folder_name#
- verbose#
- solver_version#
- callback_url#
- simulation_type#
- parent_tasks#
- jobs#
- run(path_dir='.')[source]#
Upload and run each simulation in
Batch
.- Parameters:
path_dir (str) β Base directory where data will be downloaded, by default current working directory.
- Returns:
Contains Union[
SimulationData
,HeatSimulationData
] for each Union[Simulation
,HeatSimulation
] inBatch
.- Return type:
Note
A typical usage might look like:
>>> batch_data = batch.run() >>> for task_name, sim_data in batch_data.items(): ... # do something with data.
bach_data
does not store all of the data objects in memory, rather it iterates over the task names and loads the corresponding data from file one by one. If no file exists for that task, it downloads it.
- get_info()[source]#
Get information about each task in the
Batch
.- Returns:
Mapping of task name to data about task associated with each task.
- Return type:
Dict[str,
TaskInfo
]
- start()[source]#
Start running all tasks in the
Batch
.Note
To monitor the running simulations, can call
Batch.monitor()
.
- get_run_info()[source]#
get information about a each of the tasks in the
Batch
.- Returns:
Dict[str β Maps task names to run info for each task in the
Batch
.- Return type:
RunInfo
]
- monitor()[source]#
Monitor progress of each of the running tasks.
Note
To loop through the data of completed simulations, can call
Batch.items()
.
- download(path_dir='.')[source]#
Download results of each task.
- Parameters:
path_dir (str = './') β Base directory where data will be downloaded, by default the current working directory.
- load(path_dir='.')[source]#
Download results and load them into
BatchData
object.- Parameters:
path_dir (str = './') β Base directory where data will be downloaded, by default current working directory.
- Returns:
BatchData
β Contains Union[SimulationData
,HeatSimulationData
] for each Union[Simulation
,HeatSimulation
] inBatch
.The
Batch
hdf5 file will be automatically saved as{path_dir}/batch.hdf5
,allowing one to load this
Batch
later usingbatch = Batch.from_file()
.
- real_cost(verbose=True)[source]#
Get the sum of billed costs for each task associated with this batch.
- Parameters:
verbose (bool = True) β Whether to log the cost and helpful messages.
- Returns:
Billed cost for the entire
Batch
.- Return type:
float
- estimate_cost(verbose=True)[source]#
Compute the maximum FlexCredit charge for a given
Batch
.- Parameters:
verbose (bool = True) β Whether to log the cost and helpful messages.
Note
Cost is calculated assuming the simulation runs for the full
run_time
. If early shut-off is triggered, the cost is adjusted proportionately.- Returns:
Estimated total cost of the tasks in FlexCredits.
- Return type:
float
- __hash__()#
Hash method.