tidy3d.web.api.container.Batch#

class Batch[source]#

Bases: WebContainer

Interface for submitting several Simulation objects to sever.

Parameters:
  • simulations (Attribute: simulations) –

    Type

    Mapping[str, Annotated[Union[tidy3d.components.simulation.Simulation, tidy3d.components.heat.simulation.HeatSimulation], FieldInfo(default=PydanticUndefined, discriminator=’type’, extra={})]]

    Default

    Description

    Mapping of task names to Simulations to run as a batch.

  • folder_name (Attribute: folder_name) –

    Type

    str

    Default

    = default

    Description

    Name of folder to store member of each batch on web UI.

  • verbose (Attribute: verbose) –

    Type

    bool

    Default

    = True

    Description

    Whether to print info messages and progressbars.

  • solver_version (Attribute: solver_version) –

    Type

    Optional[str]

    Default

    = None

  • callback_url (Attribute: callback_url) –

    Type

    Optional[str]

    Default

    = None

    Description

    Http PUT url to receive simulation finish event. The body content is a json file with fields {'id', 'status', 'name', 'workUnit', 'solverVersion'}.

  • simulation_type (Attribute: simulation_type) –

    Type

    str

    Default

    = tidy3d

    Description

    Type of each simulation in the batch, used internally only.

  • parent_tasks (Attribute: parent_tasks) –

    Type

    Optional[Mapping[str, Tuple[str, …]]]

    Default

    = None

    Description

    Collection of parent task ids for each job in batch, used internally only.

  • jobs (Attribute: jobs) –

    Type

    Optional[Mapping[str, Job]]

    Default

    = None

    Description

    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-in Batch object is the best way to upload, start, monitor, and load a series of tasks. The batch object is like a Job, 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 a BatchData 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_run_info()

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] in Batch.

Return type:

BatchData

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.

Note

To load and iterate through the data, use Batch.items().

The data for each task will be named as {path_dir}/{task_name}.hdf5. The Batch hdf5 file will be automatically saved as {path_dir}/batch.hdf5, allowing one to load this Batch later using batch = Batch.from_file().

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:

delete()[source]#

Delete server-side data associated with each task in the batch.

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.