Skip to content

Commit

Permalink
Fix import for older versions of Optuna
Browse files Browse the repository at this point in the history
  • Loading branch information
y0z committed Jan 15, 2024
1 parent 944b748 commit 99a54cb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion optuna_dashboard/artifact/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -182,6 +181,8 @@ def upload_study_artifact_api(study_id: int) -> dict[str, Any]:
@app.delete("/api/artifacts/<study_id:int>/<trial_id:int>/<artifact_id:re:[0-9a-fA-F-]+>")
@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."}
Expand All @@ -205,6 +206,8 @@ def delete_trial_artifact(study_id: int, trial_id: int, artifact_id: str) -> dic
@app.delete("/api/artifacts/<study_id:int>/<artifact_id:re:[0-9a-fA-F-]+>")
@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."}
Expand Down

0 comments on commit 99a54cb

Please sign in to comment.