Skip to content

Commit

Permalink
Port some e2e test scenarios to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
c-bata committed Aug 19, 2024
1 parent a0dd548 commit 1bac8e3
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 32 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/e2e-dashboard-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 }}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/e2e-standalone-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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 }}
Expand Down
Empty file removed e2e_tests/__init__.py
Empty file.
28 changes: 0 additions & 28 deletions e2e_tests/test_dashboard/visual_regression_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,33 +192,6 @@ def objective(trial: optuna.Trial) -> float:
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)
Expand Down Expand Up @@ -251,7 +224,6 @@ def run_multi_no_trials_objective_study(storage: optuna.storages.InMemoryStorage
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,
],
Expand Down
24 changes: 24 additions & 0 deletions tslib/react/test/generate_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,30 @@ def objective_intermediate_values_constraints(trial: optuna.Trial) -> float:
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()
Expand Down

0 comments on commit 1bac8e3

Please sign in to comment.