Coverage for mlos_bench/mlos_bench/tests/storage/trial_data_test.py: 100%
16 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 00:44 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-20 00:44 +0000
1#
2# Copyright (c) Microsoft Corporation.
3# Licensed under the MIT License.
4#
5"""Unit tests for loading the trial metadata."""
7from datetime import datetime
9import pytest
11from mlos_bench.environments.status import Status
12from mlos_bench.storage.base_experiment_data import ExperimentData
15def test_exp_trial_data(exp_data: ExperimentData) -> None:
16 """Check expected return values for TrialData."""
17 trial_id = 1
18 expected_config_id = 1
19 trial = exp_data.trials[trial_id]
20 assert trial.trial_id == trial_id
21 assert trial.tunable_config_id == expected_config_id
22 assert trial.status == Status.SUCCEEDED
23 assert trial.metadata_dict["repeat_i"] == 1
24 assert list(trial.results_dict.keys()) == ["score"]
25 assert trial.results_dict["score"] == pytest.approx(73.27, 0.01)
26 assert isinstance(trial.ts_start, datetime)
27 assert isinstance(trial.ts_end, datetime)
28 # Note: tests for telemetry are in test_update_telemetry()