mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-12 12:40:33 +08:00
Fix bug
This commit is contained in:
@@ -59,6 +59,13 @@ def get_trials(storage: BaseStorage, study_id: int) -> list[FrozenTrial]:
|
||||
return trials
|
||||
|
||||
|
||||
def get_trial(storage: BaseStorage, study_id: int, trial_id: int) -> FrozenTrial | None:
|
||||
for trial in get_trials(storage, study_id):
|
||||
if trial._trial_id == trial_id:
|
||||
return trial
|
||||
return None
|
||||
|
||||
|
||||
def get_study_summaries(storage: BaseStorage) -> list[StudySummary]:
|
||||
if version.parse(optuna_ver) >= version.Version("3.0.0rc0.dev"):
|
||||
frozen_studies = storage.get_all_studies() # type: ignore
|
||||
|
||||
@@ -17,7 +17,7 @@ from optuna.trial import FrozenTrial
|
||||
|
||||
from .._bottle_util import json_api_view
|
||||
from .._bottle_util import parse_data_uri
|
||||
|
||||
from .._storage import get_trial
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import Any
|
||||
@@ -103,6 +103,10 @@ def register_artifact_route(
|
||||
storage.set_study_system_attr(study_id, attr_key, json.dumps(artifact))
|
||||
response.status = 201
|
||||
|
||||
trial = get_trial(storage, study_id, trial_id)
|
||||
if trial is None:
|
||||
response.status = 400
|
||||
return {"reason": "Invalid study_id or trial_id"}
|
||||
return {
|
||||
"artifact_id": artifact_id,
|
||||
"artifacts": list_trial_artifacts(storage.get_study_system_attrs(study_id), trial),
|
||||
|
||||
Reference in New Issue
Block a user