mlos_bench.storage.sql.common

Common SQL methods for accessing the stored benchmark data.

Functions

get_results_df(→ pandas.DataFrame)

Gets TrialData for the given experiment_id and optionally additionally restricted by

get_trials(→ dict[int, ...)

Gets TrialData for the given experiment_id and optionally

save_params(→ None)

Updates a set of (param_id, param_value) tuples in the given Table.

Module Contents

mlos_bench.storage.sql.common.get_results_df(engine: sqlalchemy.engine.Engine, schema: mlos_bench.storage.sql.schema.DbSchema, experiment_id: str, tunable_config_id: int | None = None) pandas.DataFrame[source]

Gets TrialData for the given experiment_id and optionally additionally restricted by tunable_config_id.

The returned DataFrame includes each trial’s metadata, config, and results in wide format, with config parameters prefixed with ExperimentData.CONFIG_COLUMN_PREFIX and results prefixed with ExperimentData.RESULT_COLUMN_PREFIX.

Parameters:
Return type:

pandas.DataFrame

mlos_bench.storage.sql.common.get_trials(engine: sqlalchemy.engine.Engine, schema: mlos_bench.storage.sql.schema.DbSchema, experiment_id: str, tunable_config_id: int | None = None) dict[int, mlos_bench.storage.base_trial_data.TrialData][source]

Gets TrialData for the given experiment_id and optionally additionally restricted by tunable_config_id.

Parameters:
Return type:

dict[int, mlos_bench.storage.base_trial_data.TrialData]

mlos_bench.storage.sql.common.save_params(conn: sqlalchemy.engine.Connection, table: sqlalchemy.schema.Table, params: collections.abc.Mapping[str, Any], **kwargs: Any) None[source]

Updates a set of (param_id, param_value) tuples in the given Table.

Parameters:
  • conn (sqlalchemy.engine.Connection) – A connection to the backend database.

  • table (sqlalchemy.schema.Table) – The table to update.

  • params (dict[str, Any]) – The new (param_id, param_value) tuples to upsert to the Table.

  • **kwargs (dict[str, Any]) – Primary key info for the given table.

Return type:

None