Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions release/ray_release/scripts/custom_image_build_and_test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@
type=str,
help="The output file for the test jobs json file",
)
@click.option(
"--selection-block-threshold",
type=int,
default=0,
help="Number of tests to trigger before asking for confirmation when manually triggered; set to 0 to disable blocking regardless of the number of tests.",
)
def main(
test_collection_file: Tuple[str],
run_jailed_tests: bool = False,
Expand All @@ -99,6 +105,7 @@ def main(
run_per_test: int = 1,
custom_build_jobs_output_file: str = None,
test_jobs_output_file: str = None,
selection_block_threshold: int = 0,
):
global_config_file = os.path.join(
os.path.dirname(__file__), "..", "configs", global_config
Expand Down Expand Up @@ -180,8 +187,11 @@ def main(
# If the build is manually triggered and there are more than 5 tests
# Ask user to confirm before launching the tests.
block_step = None
if test_filters and len(tests) >= 5 and os.environ.get("AUTOMATIC", "") != "1":
block_step = generate_block_step(len(tests))

is_automatic = os.environ.get("AUTOMATIC", "") == "1"
if not is_automatic and test_filters and selection_block_threshold > 0:
if len(tests) >= selection_block_threshold:
block_step = generate_block_step(len(tests))
Comment on lines +260 to +263
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The logic for determining is_automatic and the subsequent conditional check can be simplified to improve readability by combining the conditions.

Suggested change
is_automatic = os.environ.get("AUTOMATIC", "") == "1"
if not is_automatic and test_filters and selection_block_threshold > 0:
if len(tests) >= selection_block_threshold:
block_step = generate_block_step(len(tests))
if os.environ.get("AUTOMATIC", "") != "1" and test_filters and selection_block_threshold > 0 and len(tests) >= selection_block_threshold:
block_step = generate_block_step(len(tests))


steps = get_step_for_test_group(
grouped_tests,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def test_custom_image_build_and_test_init_with_block_step(
custom_build_jobs_output_file,
"--test-jobs-output-file",
test_jobs_output_file,
"--selection-block-threshold",
"5",
Comment thread
cursor[bot] marked this conversation as resolved.
],
catch_exceptions=False,
)
Expand Down
Loading