Skip to content

Commit

Permalink
Merge branch 'optuna:master' into remove-jquery-extension
Browse files Browse the repository at this point in the history
  • Loading branch information
Alnusjaponica committed Jun 13, 2023
2 parents 0eb50da + 05647fb commit f9c9ec9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions optuna/progress_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import Any
from typing import Optional
from typing import TYPE_CHECKING
import warnings

from tqdm.auto import tqdm

Expand Down Expand Up @@ -45,6 +46,9 @@ def __init__(
n_trials: Optional[int] = None,
timeout: Optional[float] = None,
) -> None:
if is_valid and n_trials is None and timeout is None:
warnings.warn("Progress bar won't be displayed because n_trials and timeout are None.")

self._is_valid = is_valid and (n_trials or timeout) is not None
self._n_trials = n_trials
self._timeout = timeout
Expand Down
1 change: 0 additions & 1 deletion optuna/study/study.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,6 @@ def objective(trial):
RuntimeError:
If nested invocation of this method occurs.
"""

_optimize(
study=self,
func=func,
Expand Down
12 changes: 12 additions & 0 deletions tests/study_tests/test_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,18 @@ def objective(trial: Trial) -> float:
assert states == []


def test_optimize_infinite_budget_progbar() -> None:
def terminate_study(study: Study, trial: FrozenTrial) -> None:
study.stop()

study = create_study()

with pytest.warns(UserWarning):
study.optimize(
func, n_trials=None, timeout=None, show_progress_bar=True, callbacks=[terminate_study]
)


@pytest.mark.parametrize("storage_mode", STORAGE_MODES)
def test_get_trials(storage_mode: str) -> None:
with StorageSupplier(storage_mode) as storage:
Expand Down

0 comments on commit f9c9ec9

Please sign in to comment.