Skip to content

ExecutorSpec

Bases: Serializable

Picklable recipe for building a fresh executor of a given backend.

A spec is plain data, built either from a live loky executor (introspection, loky only) or by the submitit and mpi4py constructors. Other backends still need an explicit factory.

An instance is itself a zero-argument factory (__call__ builds and returns a new executor), so it satisfies the factory-callable requirement ParallelStrategy has for shot_executor whenever program_executor chunking is in play -- this is what lets a caller hand ParallelStrategy an ordinary live executor directly (see _introspect_executor_spec) instead of writing a factory function by hand.

ExecutorSpec

ExecutorSpec(exec_backend: str, kwargs: dict[str, Any]) -> None

Attributes

Name Type Value Doc
exec_backend str unset
kwargs dict[str, Any] unset

decode

Inherited static method from Serializable.decode().


describe

describe() -> str

Short, human-readable label, e.g. "loky(max_workers=2)".


dump

Inherited method from Serializable.dump().


encode

Inherited static method from Serializable.encode().


load

Inherited class method from Serializable.load().


mpi4py classmethod

mpi4py(**kwargs: Any) -> ExecutorSpec

Spec for an mpi4py.futures.MPIPoolExecutor.

kwargs go to MPIPoolExecutor and must be data, so worker setup such as initializer needs a factory.


read

Inherited class method from Serializable.read().


serialize_function

Inherited static method from Serializable.serialize_function().


submitit classmethod

submitit(folder: str | PathLike[str], cluster: str | None = None, **parameters: Any) -> ExecutorSpec

Spec for a submitit.AutoExecutor.

Parameters:

Name Type Description Default
folder str | PathLike[str]

Log and job folder. Stored as an absolute path, so a resume from another directory writes to the same folder.

required
cluster str | None

Submitit cluster name. None lets submitit pick the cluster when the executor is built, on the machine that builds it.

None
**parameters Any

Passed to AutoExecutor.update_parameters, so constructor-only options (such as slurm_python) need a factory. Values must be data a runner file can store (strings, numbers, booleans, None, lists, dicts).

{}

write

Inherited method from Serializable.write().