From 99a54cb28e703325132959497c0e4c67a1606c97 Mon Sep 17 00:00:00 2001 From: y0z Date: Mon, 15 Jan 2024 19:36:17 +0900 Subject: [PATCH] Fix import for older versions of Optuna --- optuna_dashboard/artifact/_backend.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/optuna_dashboard/artifact/_backend.py b/optuna_dashboard/artifact/_backend.py index b8a44abd9..a76568e21 100644 --- a/optuna_dashboard/artifact/_backend.py +++ b/optuna_dashboard/artifact/_backend.py @@ -14,7 +14,6 @@ from bottle import request from bottle import response import optuna -from optuna.artifacts.exceptions import ArtifactNotFound from optuna.trial import FrozenTrial from .._bottle_util import json_api_view @@ -182,6 +181,8 @@ def upload_study_artifact_api(study_id: int) -> dict[str, Any]: @app.delete("/api/artifacts///") @json_api_view def delete_trial_artifact(study_id: int, trial_id: int, artifact_id: str) -> dict[str, Any]: + from optuna.artifacts.exceptions import ArtifactNotFound + if artifact_store is None: response.status = 400 # Bad Request return {"reason": "Cannot access to the artifacts."} @@ -205,6 +206,8 @@ def delete_trial_artifact(study_id: int, trial_id: int, artifact_id: str) -> dic @app.delete("/api/artifacts//") @json_api_view def delete_study_artifact(study_id: int, artifact_id: str) -> dict[str, Any]: + from optuna.artifacts.exceptions import ArtifactNotFound + if artifact_store is None: response.status = 400 # Bad Request return {"reason": "Cannot access to the artifacts."}