run_batch#

LocalMechanicalPool.run_batch(files, clear_at_start=True, progress_bar=True, close_when_finished=False, timeout=None, wait=True)#

Run a batch of input files on the Mechanical instances in the pool.

Parameters:
fileslist

List of input files.

clear_at_startbool, optional

Whether to clear Mechanical when execution starts. The default is True. Setting this parameter to False might lead to instability.

progress_barbool, optional

Whether to show a progress bar when running the batch of input files. The default is True, but the progress bar is not shown when wait=False.

close_when_finishedbool, optional

Whether to close the instances when running the batch of input files is finished. The default is False.

timeoutfloat, optional

Maximum runtime in seconds for each iteration. The default is None, in which case there is no timeout. If you specify a value, each iteration is allowed to run only this number of seconds. Once this value is exceeded, the batch process is stopped and treated as a failure.

waitbool, optional

Whether block execution must wait until the batch process is complete. The default is True.

Returns:
list

List of text outputs from Mechanical for each batch run. The outputs are not necessarily listed in the order of the inputs. Failed runs do not return an output. Because the return outputs are not necessarily in the same order as iterable, you might want to add some sort of tracker or note within the input files.

Examples

Run 20 verification files on the pool.

>>> files = [f"test{index}.py" for index in range(1, 21)]
>>> outputs = pool.run_batch(files)
>>> len(outputs)
20