mirror of
https://github.com/wassname/optuna-dashboard.git
synced 2026-09-10 12:23:22 +08:00
Port some e2e test scenarios to vitest
This commit is contained in:
@@ -6,8 +6,12 @@ on:
|
||||
paths:
|
||||
- '.github/workflows/e2e-dashboard-tests.yml'
|
||||
- '**.py'
|
||||
- '**.ts'
|
||||
- '**.tsx'
|
||||
- 'tslib/**.ts'
|
||||
- 'tslib/**.tsx'
|
||||
- 'tslib/**/package.json'
|
||||
- 'tslib/**/package-lock.json'
|
||||
- 'optuna_dashboard/**.ts'
|
||||
- 'optuna_dashboard/**.tsx'
|
||||
- 'optuna_dashboard/package.json'
|
||||
- 'optuna_dashboard/package-lock.json'
|
||||
- 'optuna_dashboard/tsconfig.json'
|
||||
@@ -37,7 +41,7 @@ jobs:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.10'
|
||||
python-version: '3.11'
|
||||
architecture: x64
|
||||
|
||||
- name: Setup Optuna ${{ matrix.optuna-version }}
|
||||
|
||||
@@ -5,6 +5,10 @@ on:
|
||||
- main
|
||||
paths:
|
||||
- '.github/workflows/e2e-standalone-tests.yml'
|
||||
- 'tslib/**.ts'
|
||||
- 'tslib/**.tsx'
|
||||
- 'tslib/**/package.json'
|
||||
- 'tslib/**/package-lock.json'
|
||||
- 'standalone_app/**.ts'
|
||||
- 'standalone_app/**.tsx'
|
||||
- 'standalone_app/package.json'
|
||||
@@ -34,7 +38,7 @@ jobs:
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.10'
|
||||
python-version: '3.11'
|
||||
architecture: x64
|
||||
|
||||
- name: Setup Optuna ${{ matrix.optuna-version }}
|
||||
|
||||
@@ -192,33 +192,6 @@ def run_single_inf_report_objective_study(
|
||||
return study
|
||||
|
||||
|
||||
def run_issue_410_objective_study(storage: optuna.storages.InMemoryStorage) -> optuna.Study:
|
||||
# Issue 410
|
||||
sampler = optuna.samplers.RandomSampler(seed=0)
|
||||
study = optuna.create_study(study_name="issue-410", storage=storage, sampler=sampler)
|
||||
|
||||
def objective(trial: optuna.Trial) -> float:
|
||||
trial.suggest_categorical("resample_rate", ["50ms"])
|
||||
trial.suggest_categorical("channels", ["all"])
|
||||
trial.suggest_categorical("window_size", [256])
|
||||
if trial.number > 15:
|
||||
raise Exception("Unexpected error")
|
||||
trial.suggest_categorical("cbow", [True])
|
||||
trial.suggest_categorical("model", ["m1"])
|
||||
|
||||
trial.set_user_attr("epochs", 0)
|
||||
trial.set_user_attr("deterministic", True)
|
||||
if trial.number > 10:
|
||||
raise Exception("unexpeccted error")
|
||||
trial.set_user_attr("folder", "/path/to/folder")
|
||||
trial.set_user_attr("resample_type", "foo")
|
||||
trial.set_user_attr("run_id", "0001")
|
||||
return 1.0
|
||||
|
||||
study.optimize(objective, n_trials=20, catch=(Exception,))
|
||||
return study
|
||||
|
||||
|
||||
def run_single_no_trials_objective_study(storage: optuna.storages.InMemoryStorage) -> optuna.Study:
|
||||
# No trials single-objective study
|
||||
sampler = optuna.samplers.RandomSampler(seed=0)
|
||||
@@ -251,7 +224,6 @@ parameterize_studies = pytest.mark.parametrize(
|
||||
run_multi_dynamic_objective_study,
|
||||
run_single_pruned_without_report_objective_study,
|
||||
run_single_inf_report_objective_study,
|
||||
run_issue_410_objective_study,
|
||||
run_single_no_trials_objective_study,
|
||||
run_multi_no_trials_objective_study,
|
||||
],
|
||||
|
||||
@@ -447,6 +447,30 @@ def create_optuna_storage(
|
||||
trial.report(trial.number, step=0)
|
||||
trial.report(trial.number + 1, step=1)
|
||||
|
||||
# optuna-dashboard issue 410
|
||||
# https://github.com/optuna/optuna-dashboard/issues/410
|
||||
study = optuna.create_study(study_name="optuna-dashboard-issue-410", storage=storage, sampler=optuna.samplers.RandomSampler())
|
||||
|
||||
def objective_issue_410(trial: optuna.Trial) -> float:
|
||||
trial.suggest_categorical("resample_rate", ["50ms"])
|
||||
trial.suggest_categorical("channels", ["all"])
|
||||
trial.suggest_categorical("window_size", [256])
|
||||
if trial.number > 15:
|
||||
raise Exception("Unexpected error")
|
||||
trial.suggest_categorical("cbow", [True])
|
||||
trial.suggest_categorical("model", ["m1"])
|
||||
|
||||
trial.set_user_attr("epochs", 0)
|
||||
trial.set_user_attr("deterministic", True)
|
||||
if trial.number > 10:
|
||||
raise Exception("unexpeccted error")
|
||||
trial.set_user_attr("folder", "/path/to/folder")
|
||||
trial.set_user_attr("resample_type", "foo")
|
||||
trial.set_user_attr("run_id", "0001")
|
||||
return 1.0
|
||||
|
||||
study.optimize(objective_issue_410, n_trials=20, catch=(Exception,))
|
||||
|
||||
|
||||
def main() -> None:
|
||||
remove_assets()
|
||||
|
||||
Reference in New Issue
Block a user