boa.wrapper.BaseWrapper#
- class boa.wrapper.BaseWrapper(config_path: Optional[PathLike] = None, *args, **kwargs)[source]#
Bases:
objectMethods
Retrieves the trial data and prepares it for the metric(s) used in the objective function.
Load config file and return a dictionary # TODO finish this
Make the experiment directory that boa will write all of its trials and logs to.
Runs a model by deploying a given trial.
Marks the status of a trial to reflect the status of the model run for the trial.
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_path: PathLike, *args, **kwargs)[source]#
Load config file and return a dictionary # TODO finish this
- Parameters
config_path (os.PathLike) – File path for the experiment configuration file
- Returns
loaded_config
- Return type
dict
- mk_experiment_dir(experiment_dir: PathLike = None, working_dir: PathLike = None, experiment_name: str = None, append_timestamp: bool = True, **kwargs)[source]#
Make the experiment directory that boa will write all of its trials and logs to.
- Parameters
experiment_dir (os.PathLike) – Path to the directory for the output of the experiment You may specify this or working_dir in your configuration file instead. (Defaults to None and using your configuration file instead)
working_dir (os.PathLike) – Working directory of project, experiment_dir will be placed inside working dir based on experiment name. Because of this only either experiment_dir or working_dir may be specified. You may specify this or experiment_dir in your configuration file instead. (Defaults to None and using your configuration file instead)
experiment_name (str) – Name of experiment, used for creating path to experiment dir with the working dir (Defaults to None and using your configuration file instead)
append_timestamp (bool) – Whether to append a timestamp to the end of the experiment directory to ensure uniqueness
- 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