boa.runner.WrappedJobRunner#

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

Bases: Runner

Methods

clone

Create a copy of this Runner.

deserialize_init_args

Given a dictionary, deserialize the properties needed to initialize the runner.

poll_available_capacity

Checks how much available capacity there is to schedule trial evaluations.

poll_trial_status

Checks the status of any non-terminal trials and returns their indices as a mapping from TrialStatus to a list of indices.

run

Deploys a trial based on custom runner subclass implementation.

run_multiple

Runs a single evaluation for each of the given trials.

serialize_init_args

Serialize the properties needed to initialize the runner.

stop

Stop a trial based on custom runner subclass implementation.

to_dict

Convert Ax synthetic runner to a dictionary.

Attributes

db_id

staging_required

Whether the trial goes to staged or running state once deployed.

clone() Runner#

Create a copy of this Runner.

classmethod deserialize_init_args(args: Dict[str, Any]) Dict[str, Any]#

Given a dictionary, deserialize the properties needed to initialize the runner. Used for storage.

poll_available_capacity() int#

Checks how much available capacity there is to schedule trial evaluations. Required for runners used with Ax Scheduler.

NOTE: This method might be difficult to implement in some systems. Returns -1 if capacity of the system is “unlimited” or “unknown” (meaning that the Scheduler should be trying to schedule as many trials as is possible without violating scheduler settings). There is no need to artificially force this method to limit capacity; Scheduler has other limitations in place to limit number of trials running at once, like the SchedulerOptions.max_pending_trials setting, or more granular control in the form of the max_parallelism setting in each of the GenerationStep`s of a `GenerationStrategy).

Returns

An integer, representing how many trials there is available capacity for; -1 if capacity is “unlimited” or not possible to know in advance.

poll_trial_status(trials: Iterable[BaseTrial]) 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 – 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).

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

Deploys a trial based on custom runner subclass implementation.

Parameters

trial – The trial to deploy.

Returns

Dict of run metadata from the deployment process.

run_multiple(trials: Iterable[core.base_trial.BaseTrial]) Dict[int, Dict[str, Any]]#

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.

classmethod serialize_init_args(runner: Runner) Dict[str, Any]#

Serialize the properties needed to initialize the runner. Used for storage.

property staging_required: bool#

Whether the trial goes to staged or running state once deployed.

stop(trial: core.base_trial.BaseTrial, reason: Optional[str] = None) Dict[str, Any]#

Stop a trial based on custom runner subclass implementation.

Optional method.

Parameters
  • trial – The trial to stop.

  • reason – A message containing information why the trial is to be stopped.

Returns

A dictionary of run metadata from the stopping process.

to_dict() dict[source]#

Convert Ax synthetic runner to a dictionary.