boa.wrapper.BaseWrapper#

class boa.wrapper.BaseWrapper[source]#

Bases: object

Methods

fetch_trial_data

Retrieves the trial data and prepares it for the metric(s) used in the objective function.

load_config

Load config file and return a dictionary # TODO finish this

run_model

Runs a model by deploying a given trial.

set_trial_status

Marks the status of a trial to reflect the status of the model run for the trial.

write_configs

This function is usually used to write out the configurations files used in an individual optimization trial run, or to dynamically write a run script to start an optimization trial run.

fetch_trial_data(trial: BaseTrial, metric_properties: dict, metric_name: str, *args, **kwargs) dict[source]#

Retrieves the trial data and prepares it for the metric(s) used in the objective function.

For example, for a case where you are minimizing the error between a model and observations, using RMSE as a metric, this function would load the model output and the corresponding observation data that will be passed to the RMSE metric.

The return value of this function is a dictionary, with keys that match the keys of the metric used in the objective function. # TODO work on this description

Parameters
  • trial (BaseTrial) –

  • metric_properties (dict) –

  • metric_name (str) –

Returns

A dictionary with the keys matching the keys of the metric function

used in the objective

Return type

dict

load_config(config_file: PathLike)[source]#

Load config file and return a dictionary # TODO finish this

Parameters

config_file (os.PathLike) – File path for the experiment configuration file

Returns

loaded_config

Return type

dict

run_model(trial: BaseTrial) None[source]#

Runs a model by deploying a given trial.

Parameters

trial (BaseTrial) –

set_trial_status(trial: BaseTrial) None[source]#

Marks the status of a trial to reflect the status of the model run for the trial.

Each trial will be polled periodically to determine its status (completed, failed, still running, etc). This function defines the criteria for determining the status of the model run for a trial (e.g., whether the model run is completed/still running, failed, etc). The trial status is updated accordingly when the trial is polled.

The approach for determining the trial status will depend on the structure of the particular model and its outputs. One example is checking the log files of the model.

Todo

Add examples/links of different approaches

Parameters

trial (BaseTrial) –

Examples

trial.mark_completed() trial.mark_failed() trial.mark_abandoned() trial.mark_early_stopped()

See also

# TODO add sphinx link to ax trial status

write_configs(trial: BaseTrial) None[source]#

This function is usually used to write out the configurations files used in an individual optimization trial run, or to dynamically write a run script to start an optimization trial run.

Parameters

trial (BaseTrial) –