Skip to content

Fix fragile test_brute_force.py#6209

Closed
gen740 wants to merge 5 commits intooptuna:masterfrom
gen740:fix_fragile_brute_force_test
Closed

Fix fragile test_brute_force.py#6209
gen740 wants to merge 5 commits intooptuna:masterfrom
gen740:fix_fragile_brute_force_test

Conversation

@gen740
Copy link
Copy Markdown
Member

@gen740 gen740 commented Jul 18, 2025

Motivation

Related to #6206.

Description of the changes

Under the high-load environment (like ci with xdist), the sleep(1) is not enough to guarantee the suggestion order. So I fixed it to guarantee the suggestion order.

@gen740 gen740 force-pushed the fix_fragile_brute_force_test branch from bd63b09 to aca6bdf Compare July 18, 2025 06:17
@nabenabe0928 nabenabe0928 changed the title Fix fragile test_brute_force.py Fix fragile test_brute_force.py Jul 22, 2025
@nabenabe0928 nabenabe0928 changed the title Fix fragile test_brute_force.py Fix fragile test_brute_force.py Jul 22, 2025
Co-authored-by: Shuhei Watanabe <47781922+nabenabe0928@users.noreply.github.com>
limit = 200 # avoid infinite after 100 seconds

# Guarantee that the trial with x=0 is completed before the trial with x=1.
while len(study.get_trials(states=[optuna.trial.TrialState.COMPLETE])) < 2:
Copy link
Copy Markdown
Contributor

@nabenabe0928 nabenabe0928 Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about using this directly?
I think checking study._stop_flag is more direct and sure.

Suggested change
while len(study.get_trials(states=[optuna.trial.TrialState.COMPLETE])) < 2:
while not study._stop_flag:

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think study._stop_flag indicates that the optimization loop has finished.
But in this case, I want to wait only until the first two trials have completed (while one trial remains RUNNING).
So I don’t think study._stop_flag would become True here.

@nabenabe0928 nabenabe0928 added the CI Continuous integration. label Jul 22, 2025
@nabenabe0928 nabenabe0928 added this to the v4.5.0 milestone Jul 22, 2025
@nabenabe0928 nabenabe0928 self-assigned this Jul 22, 2025
@github-actions
Copy link
Copy Markdown
Contributor

This pull request has not seen any recent activity.

@github-actions github-actions bot added the stale Exempt from stale bot labeling. label Jul 29, 2025
@c-bata c-bata marked this pull request as draft August 1, 2025 06:02
@github-actions github-actions bot removed the stale Exempt from stale bot labeling. label Aug 3, 2025
@gen740
Copy link
Copy Markdown
Member Author

gen740 commented Aug 8, 2025

I will create the new PR for this test.

@gen740 gen740 closed this Aug 8, 2025
@gen740 gen740 deleted the fix_fragile_brute_force_test branch August 8, 2025 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI Continuous integration.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants