mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-12 12:40:33 +08:00
Fix broken tests
This commit is contained in:
@@ -43,10 +43,11 @@ from ._serializer import serialize_study_summary
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
from _typeshed.wsgi import WSGIApplication
|
||||
|
||||
try:
|
||||
from optuna.study._frozen import FrozenStudy
|
||||
except ImportError:
|
||||
FrozenStudy = None
|
||||
FrozenStudy = None # type: ignore
|
||||
|
||||
BottleViewReturn = Union[str, bytes, Dict[str, Any], BaseResponse]
|
||||
BottleView = TypeVar("BottleView", bound=Callable[..., BottleViewReturn])
|
||||
@@ -141,10 +142,7 @@ def json_api_view(view: BottleView) -> BottleView:
|
||||
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
|
||||
return [
|
||||
_frozen_study_to_study_summary(s)
|
||||
for s in frozen_studies
|
||||
]
|
||||
return [_frozen_study_to_study_summary(s) for s in frozen_studies]
|
||||
elif version.parse(optuna_ver) >= version.Version("3.0.0b0.dev"):
|
||||
return storage.get_all_study_summaries(include_best_trial=False) # type: ignore
|
||||
else:
|
||||
|
||||
@@ -1,25 +1,13 @@
|
||||
import json
|
||||
from typing import List
|
||||
from unittest import TestCase
|
||||
|
||||
import optuna
|
||||
from optuna.storages import BaseStorage
|
||||
from optuna.study import StudySummary
|
||||
from optuna.version import __version__ as optuna_ver
|
||||
from optuna import get_all_study_summaries
|
||||
from optuna_dashboard._app import create_app
|
||||
from packaging import version
|
||||
|
||||
from .wsgi_client import send_request
|
||||
|
||||
|
||||
def get_all_study_summaries(storage: BaseStorage) -> List[StudySummary]:
|
||||
if version.parse(optuna_ver) >= version.Version("3.0.0b0.dev"):
|
||||
summaries = storage.get_all_study_summaries(include_best_trial=True) # type: ignore
|
||||
else:
|
||||
summaries = storage.get_all_study_summaries() # type: ignore
|
||||
return summaries
|
||||
|
||||
|
||||
def objective(trial: optuna.trial.Trial) -> float:
|
||||
x = trial.suggest_float("x", -1, 1)
|
||||
return x
|
||||
|
||||
@@ -9,9 +9,8 @@ from typing import Tuple
|
||||
from wsgiref.simple_server import make_server
|
||||
|
||||
import optuna
|
||||
from optuna.version import __version__ as optuna_ver
|
||||
from optuna import get_all_study_summaries
|
||||
from optuna_dashboard import wsgi
|
||||
from packaging import version
|
||||
from pyppeteer import launch
|
||||
from pyppeteer.page import Page
|
||||
|
||||
@@ -186,10 +185,7 @@ async def take_screenshots(storage: optuna.storages.BaseStorage) -> List[str]:
|
||||
time.sleep(1)
|
||||
await page.screenshot({"path": os.path.join(args.output_dir, "study-list.png")})
|
||||
|
||||
if version.parse(optuna_ver) >= version.Version("3.0.0b0.dev"):
|
||||
summaries = storage.get_all_study_summaries(include_best_trial=True) # type: ignore
|
||||
else:
|
||||
summaries = storage.get_all_study_summaries() # type: ignore
|
||||
summaries = get_all_study_summaries(storage)
|
||||
study_ids = {s._study_id: s.study_name for s in summaries}
|
||||
for study_id, study_name in study_ids.items():
|
||||
await page.goto(f"http://{args.host}:{args.port}/dashboard/studies/{study_id}")
|
||||
|
||||
Reference in New Issue
Block a user