mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-09 11:28:14 +08:00
Merge pull request #196 from optuna/study-summary-v3
Set include_best_trial=True to get study summaries for v3 release
This commit is contained in:
@@ -14,6 +14,9 @@ on:
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
optuna-version: ['optuna==2.10.0', 'git+https://github.com/optuna/optuna.git']
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
@@ -29,11 +32,14 @@ jobs:
|
||||
with:
|
||||
python-version: '3.8'
|
||||
architecture: x64
|
||||
- name: Install dependencies
|
||||
- name: Setup Optuna ${{ matrix.optuna-version }}
|
||||
run: |
|
||||
python -m pip install --progress-bar off --upgrade pip setuptools
|
||||
pip install --progress-bar off .
|
||||
pip install --progress-bar off pyppeteer
|
||||
python -m pip install --progress-bar off --upgrade ${{ matrix.optuna-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --progress-bar off .
|
||||
python -m pip install --progress-bar off pyppeteer
|
||||
|
||||
- name: Cache headless chromium
|
||||
id: cache-chromium
|
||||
|
||||
@@ -30,6 +30,8 @@ from optuna.storages import RedisStorage
|
||||
from optuna.study import StudyDirection
|
||||
from optuna.study import StudySummary
|
||||
from optuna.trial import FrozenTrial
|
||||
from optuna.version import __version__ as optuna_ver
|
||||
from packaging import version
|
||||
|
||||
from . import _note as note
|
||||
from ._importance import get_param_importance_from_trials_cache
|
||||
@@ -75,7 +77,10 @@ def json_api_view(view: BottleView) -> BottleView:
|
||||
|
||||
|
||||
def get_study_summary(storage: BaseStorage, study_id: int) -> Optional[StudySummary]:
|
||||
summaries = storage.get_all_study_summaries()
|
||||
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
|
||||
for summary in summaries:
|
||||
if summary._study_id != study_id:
|
||||
continue
|
||||
@@ -121,12 +126,13 @@ def create_app(storage: BaseStorage, debug: bool = False) -> Bottle:
|
||||
@app.get("/api/studies")
|
||||
@json_api_view
|
||||
def list_study_summaries() -> BottleViewReturn:
|
||||
summaries = [
|
||||
serialize_study_summary(summary)
|
||||
for summary in storage.get_all_study_summaries()
|
||||
]
|
||||
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
|
||||
serialized = [serialize_study_summary(summary) for summary in summaries]
|
||||
return {
|
||||
"study_summaries": summaries,
|
||||
"study_summaries": serialized,
|
||||
}
|
||||
|
||||
@app.post("/api/studies")
|
||||
|
||||
@@ -29,6 +29,7 @@ include_package_data = False
|
||||
packages = find:
|
||||
install_requires =
|
||||
optuna>=2.4
|
||||
packaging
|
||||
bottle
|
||||
typing-extensions;python_version<'3.8'
|
||||
scikit-learn
|
||||
|
||||
@@ -10,6 +10,8 @@ from typing import Tuple
|
||||
from wsgiref.simple_server import make_server
|
||||
|
||||
import optuna
|
||||
from optuna.version import __version__ as optuna_ver
|
||||
from packaging import version
|
||||
from pyppeteer import launch
|
||||
from pyppeteer.page import Page
|
||||
|
||||
@@ -196,7 +198,11 @@ 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")})
|
||||
|
||||
study_ids = {s._study_id: s.study_name for s in storage.get_all_study_summaries()}
|
||||
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
|
||||
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}")
|
||||
time.sleep(args.sleep)
|
||||
|
||||
Reference in New Issue
Block a user