Wrapped Runner#

Runner that calls your wrappers to run your model and poll the trial status.

class boa.runner.WrappedJobRunner(wrapper: Optional[BaseWrapper] = None, *args, **kwargs)[source]#

Bases: Runner

Parameters

wrapper (BaseWrapper) –

run(trial: Trial) Dict[str, Any][source]#

Deploys a trial based on custom runner subclass implementation.

Add a logging queue handler to the boa and ax root loggers to capture logs from the wrapper.

Parameters

trial (Trial) – The trial to deploy.

Returns

Dict of run metadata from the deployment process.

Return type

Dict[str, Any]

run_multiple(trials) Dict[int, Dict[str, Any]][source]#

Runs a single evaluation for each of the given trials. Useful when deploying multiple trials at once is more efficient than deploying them one-by-one. Used in Ax Scheduler.

NOTE: By default simply loops over run_trial. Should be overwritten if deploying multiple trials in batch is preferable.

Parameters

trials – Iterable of trials to be deployed, each containing arms with parameterizations to be evaluated. Can be a Trial if contains only one arm or a BatchTrial if contains multiple arms.

Returns

Dict of trial index to the run metadata of that trial from the deployment process.

Return type

Dict[int, Dict[str, Any]]

poll_trial_status(trials: Iterable[Trial]) Dict[TrialStatus, Set[int]][source]#

Checks the status of any non-terminal trials and returns their indices as a mapping from TrialStatus to a list of indices. Required for runners used with Ax Scheduler.

NOTE: Does not need to handle waiting between polling calls while trials are running; this function should just perform a single poll.

Parameters

trials (Iterable[Trial]) – Trials to poll.

Returns

A dictionary mapping TrialStatus to a list of trial indices that have the respective status at the time of the polling. This does not need to include trials that at the time of polling already have a terminal (ABANDONED, FAILED, COMPLETED) status (but it may).

Return type

Dict[TrialStatus, Set[int]]

to_dict() dict[source]#

Convert runner to a dictionary.

Return type

dict