Skip to content

Execution

Execution is delegated out of Experiment into two collaborators:

  • An execution plugin (e.g., SerialExecution, ParallelExecution, or AsyncExecution) that drives the replicate loop via run_experiment_loop.
  • ResultAggregator (from crystallize.experiments.aggregation) which collates replicate outputs, seeds, provenance, and metrics into a Result.

Experiment.run/arun selects the strategy plugin, passes in the replicate callable, and then hands the collected replicate results to ResultAggregator. Override or swap these collaborators instead of subclassing Experiment to change aggregation behavior; the legacy _aggregate_results hook is no longer part of the execution path.

  • TYPE_CHECKING
  • VALID_EXECUTOR_TYPES

Execute replicates one after another within the main process.

__init__(progress: 'bool' = False) → None

method SerialExecution.run_experiment_loop

Section titled “method SerialExecution.run_experiment_loop”
run_experiment_loop(
experiment: "'Experiment'",
replicate_fn: 'Callable[[int], Any]'
) → List[Any]

Run SYNC replicates concurrently using ThreadPoolExecutor or ProcessPoolExecutor.

__init__(
max_workers: 'Optional[int]' = None,
executor_type: 'str' = 'thread',
progress: 'bool' = False
) → None

method ParallelExecution.run_experiment_loop

Section titled “method ParallelExecution.run_experiment_loop”
run_experiment_loop(
experiment: "'Experiment'",
replicate_fn: 'Callable[[int], Any]'
) → List[Any]

Run async replicates concurrently using asyncio.gather.

__init__(progress: 'bool' = False) → None

run_experiment_loop(
experiment: "'Experiment'",
replicate_fn: 'Callable[[int], Any]'
) → List[Any]