Skip to content

The test test_parallel_optimize_with_sleep eventually fails #6095

@HideakiImamura

Description

@HideakiImamura

Expected behavior

The test test_parallel_optimize_with_sleep must succeeds.

Environment

  • Optuna version: Current master
  • Python version: 3.9
  • OS: Linux
  • (Optional) Other libraries and their versions:

Error messages, stack traces, or logs

______________________ test_parallel_optimize_with_sleep _______________________

    def test_parallel_optimize_with_sleep() -> None:
        def objective(trial: Trial) -> float:
            x = trial.suggest_int("x", 0, 1)
            time.sleep(x)
            y = trial.suggest_int("y", 0, 1)
            return x + y
    
        # Seed is fixed to reproduce the same result.
        # See: https://github.com/optuna/optuna/issues/5780
        study = optuna.create_study(sampler=samplers.BruteForceSampler(seed=42))
        study.optimize(objective, n_jobs=2)
        expected_suggested_values = [
            {"x": 0, "y": 0},
            {"x": 0, "y": 1},
            {"x": 1, "y": 0},
        ]
        all_suggested_values = [t.params for t in study.trials]
>       assert len(all_suggested_values) == len(expected_suggested_values)
E       AssertionError: assert 4 == 3
E        +  where 4 = len([{'x': 0, 'y': 1}, {'x': 1, 'y': 1}, {'x': 1, 'y': 0}, {'x': 0, 'y': 0}])
E        +  and   3 = len([{'x': 0, 'y': 0}, {'x': 0, 'y': 1}, {'x': 1, 'y': 0}])

tests/samplers_tests/test_brute_force.py:324: AssertionError

Steps to reproduce

See https://github.com/optuna/optuna/actions/runs/15263202365/job/42924451020

Additional context (optional)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions