Skip to content

Commit

Permalink
Use metric_names attribute instead of querying the storage directly
Browse files Browse the repository at this point in the history
  • Loading branch information
xadrianzetx committed Sep 17, 2023
1 parent 7a1522f commit 60a3552
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 11 deletions.
5 changes: 1 addition & 4 deletions optuna/study/_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import optuna
from optuna._imports import try_import
from optuna.study.study import _SYSTEM_ATTR_METRIC_NAMES
from optuna.trial._state import TrialState


Expand Down Expand Up @@ -41,9 +40,7 @@ def _create_records_and_aggregate_column(
column_agg: DefaultDict[str, Set] = collections.defaultdict(set)
non_nested_attr = ""

metric_names = study._storage.get_study_system_attrs(study._study_id).get(
_SYSTEM_ATTR_METRIC_NAMES
)
metric_names = study.metric_names

records = []
for trial in study.get_trials(deepcopy=False):
Expand Down
4 changes: 1 addition & 3 deletions optuna/study/study.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,9 +1088,7 @@ def _log_completed_trial(self, trial: trial_module.FrozenTrial) -> None:
if not _logger.isEnabledFor(logging.INFO):
return

metric_names = self._storage.get_study_system_attrs(self._study_id).get(
_SYSTEM_ATTR_METRIC_NAMES
)
metric_names = self.metric_names

if len(trial.values) > 1:
trial_values: list[float] | dict[str, float]
Expand Down
5 changes: 1 addition & 4 deletions optuna/visualization/_pareto_front.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from optuna.exceptions import ExperimentalWarning
from optuna.study import Study
from optuna.study._multi_objective import _get_pareto_front_trials_by_trials
from optuna.study.study import _SYSTEM_ATTR_METRIC_NAMES
from optuna.trial import FrozenTrial
from optuna.trial import TrialState
from optuna.visualization._plotly_imports import _imports
Expand Down Expand Up @@ -343,9 +342,7 @@ def _infer_n_targets(
)

if target_names is None:
metric_names = study._storage.get_study_system_attrs(study._study_id).get(
_SYSTEM_ATTR_METRIC_NAMES
)
metric_names = study.metric_names
if metric_names is None:
target_names = [f"Objective {i}" for i in range(n_targets)]
else:
Expand Down

0 comments on commit 60a3552

Please sign in to comment.