From 3f4e118b5d3f454d04ac0d53e54b1dccccbfaedc Mon Sep 17 00:00:00 2001 From: moririn2528 Date: Wed, 16 Aug 2023 14:49:38 +0900 Subject: [PATCH] fix by review --- optuna_dashboard/_app.py | 8 ++------ optuna_dashboard/preferential/_system_attrs.py | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/optuna_dashboard/_app.py b/optuna_dashboard/_app.py index 53a98df7..7aae8864 100644 --- a/optuna_dashboard/_app.py +++ b/optuna_dashboard/_app.py @@ -275,12 +275,8 @@ def create_app( response.status = 400 # Bad request return {"reason": "You need to set best_trials and worst_trials"} - try: - preferences = [(best, worst) for best in best_trials for worst in worst_trials] - report_preferences(study_id, storage, preferences) - except Exception as e: - response.status = 500 - return {"reason": f"Internal server error: {e}"} + preferences = [(best, worst) for best in best_trials for worst in worst_trials] + report_preferences(study_id, storage, preferences) response.status = 204 return {} diff --git a/optuna_dashboard/preferential/_system_attrs.py b/optuna_dashboard/preferential/_system_attrs.py index 3b73c12b..fdd9db35 100644 --- a/optuna_dashboard/preferential/_system_attrs.py +++ b/optuna_dashboard/preferential/_system_attrs.py @@ -14,7 +14,7 @@ _SYSTEM_ATTR_PREFIX_PREFERENCE = "preference:values" def report_preferences( study_id: int, storage: BaseStorage, - preferences: list[tuple[int, int]], # element is number of trail + preferences: list[tuple[int, int]], ) -> None: key = _SYSTEM_ATTR_PREFIX_PREFERENCE + str(uuid.uuid4()) storage.set_study_system_attr(