From 4570efe74db693276482aa946bfec4be7cec3064 Mon Sep 17 00:00:00 2001 From: moririn2528 Date: Thu, 14 Sep 2023 16:39:44 +0900 Subject: [PATCH] fix by review --- docs/api.rst | 1 + optuna_dashboard/_app.py | 4 ++-- optuna_dashboard/_preference_setting.py | 4 ++-- python_tests/test_api.py | 4 ++-- python_tests/test_preference_setting.py | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index aadd2718..e66ae468 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -44,6 +44,7 @@ Preferential Optimization optuna_dashboard.preferential.create_study optuna_dashboard.preferential.load_study optuna_dashboard.preferential.PreferentialStudy + optuna_dashboard._prefential_setting.register_preference_feedback_component Streamlit ----------------- diff --git a/optuna_dashboard/_app.py b/optuna_dashboard/_app.py index 4c22bdbf..3abac3fc 100644 --- a/optuna_dashboard/_app.py +++ b/optuna_dashboard/_app.py @@ -28,7 +28,7 @@ from ._cached_extra_study_property import get_cached_extra_study_property from ._custom_plot_data import get_plotly_graph_objects from ._importance import get_param_importance_from_trials_cache from ._pareto_front import get_pareto_front_trials -from ._preference_setting import _register_preference_feedback_component_type +from ._preference_setting import _register_preference_feedback_component from ._preferential_history import NewHistory from ._preferential_history import PreferenceHistoryNotFound from ._preferential_history import remove_history @@ -323,7 +323,7 @@ def create_app( response.status = 400 return {"reason": "component_type must be either 'Note' or 'Artifact'."} - _register_preference_feedback_component_type( + _register_preference_feedback_component( study_id=study_id, storage=storage, component_type=component_type, diff --git a/optuna_dashboard/_preference_setting.py b/optuna_dashboard/_preference_setting.py index d0f8c82c..907fc2be 100644 --- a/optuna_dashboard/_preference_setting.py +++ b/optuna_dashboard/_preference_setting.py @@ -16,7 +16,7 @@ if TYPE_CHECKING: _SYSTEM_ATTR_FEEDBACK_COMPONENT = "preference:component" -def _register_preference_feedback_component_type( +def _register_preference_feedback_component( study_id: int, storage: BaseStorage, component_type: OUTPUT_COMPONENT_TYPE, @@ -59,7 +59,7 @@ def register_preference_feedback_component( artifact_key is not None ), "artifact_key must be specified when component_type is Artifact" - _register_preference_feedback_component_type( + _register_preference_feedback_component( study_id=study._study._study_id, storage=study._study._storage, component_type=component_type, diff --git a/python_tests/test_api.py b/python_tests/test_api.py index d5de330d..db79c0d8 100644 --- a/python_tests/test_api.py +++ b/python_tests/test_api.py @@ -8,7 +8,7 @@ from optuna import get_all_study_summaries from optuna.study import StudyDirection from optuna_dashboard._app import create_app from optuna_dashboard._app import create_new_study -from optuna_dashboard._preference_setting import register_preference_feedback_component_type +from optuna_dashboard._preference_setting import register_preference_feedback_component from optuna_dashboard._preferential_history import NewHistory from optuna_dashboard._preferential_history import remove_history from optuna_dashboard._preferential_history import report_history @@ -187,7 +187,7 @@ class APITestCase(TestCase): def test_change_component(self) -> None: storage = optuna.storages.InMemoryStorage() study = create_study(storage=storage, n_generate=3) - register_preference_feedback_component_type(study, "note") + register_preference_feedback_component(study, "note") for _ in range(3): study.ask() diff --git a/python_tests/test_preference_setting.py b/python_tests/test_preference_setting.py index bcd53e42..a0adcb39 100644 --- a/python_tests/test_preference_setting.py +++ b/python_tests/test_preference_setting.py @@ -4,14 +4,14 @@ from unittest import TestCase import optuna from optuna_dashboard._preference_setting import _SYSTEM_ATTR_FEEDBACK_COMPONENT -from optuna_dashboard._preference_setting import register_preference_feedback_component_type +from optuna_dashboard._preference_setting import register_preference_feedback_component from optuna_dashboard.preferential._study import PreferentialStudy class FeedbackSettingTestCase(TestCase): def test_widget_to_dict_from_dict(self) -> None: study = PreferentialStudy(optuna.create_study()) - register_preference_feedback_component_type(study, "artifact", "image_key") + register_preference_feedback_component(study, "artifact", "image_key") system_attrs = study._study.system_attrs feedback_type = system_attrs.get(_SYSTEM_ATTR_FEEDBACK_COMPONENT, {}) assert "type" in feedback_type