Skip to content

Conversation

khluu
Copy link
Contributor

@khluu khluu commented Aug 15, 2025

  • This filter test func can now use either or both of name prefix filter or regex filter. If both are used at the same time, test matches either of the filter is accepted

p
Signed-off-by: kevin <kevin@anyscale.com>
@khluu khluu requested a review from aslonnie August 15, 2025 22:00
@khluu khluu requested a review from a team as a code owner August 15, 2025 22:00
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds a new option to filter tests by a name prefix, complementing the existing regex-based attribute filtering. The implementation correctly applies an 'OR' logic when both filters are used. The added tests cover the new functionality well. I've suggested a small refactoring to improve the readability of the filtering logic.

Comment on lines 41 to 62
# If no filter, select all tests
selected = not (test_name_prefix_filter or test_attr_regex_filters)

# Check if test name matches prefix filter
if test_name_prefix_filter and test.get_name().startswith(
test_name_prefix_filter
):
selected = True

# Check if any test attributes match regex filters
if test_attr_regex_filters:
attr_mismatch = False
for attr, regex in test_attr_regex_filters.items():
attr_value = _unflattened_lookup(test, attr) or ""
if not re.fullmatch(regex, attr_value):
attr_mismatch = True
break
if not attr_mismatch:
selected = True

if not selected:
continue
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The current filtering logic using the selected flag is a bit complex to follow. It can be refactored to be more explicit and readable by checking for each filter condition separately and combining them with a clear or.

        # If filters are provided, a test is selected if it matches at least one of them.
        # If no filters are provided, all tests are selected.
        if test_name_prefix_filter or test_attr_regex_filters:
            prefix_match = test_name_prefix_filter and test.get_name().startswith(
                test_name_prefix_filter
            )

            regex_match = False
            if test_attr_regex_filters:
                regex_match = all(
                    re.fullmatch(regex, _unflattened_lookup(test, attr) or "")
                    for attr, regex in test_attr_regex_filters.items()
                )

            if not (prefix_match or regex_match):
                continue

@ray-gardener ray-gardener bot added core Issues that should be addressed in Ray Core devprod release-test release test labels Aug 16, 2025
test_collection: List[Test],
frequency: Frequency,
test_attr_regex_filters: Optional[Dict[str, str]] = None,
test_name_prefix_filter: Optional[str] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

how does one set this? this seems to be unused yet? is there a followup PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Comment on lines 41 to 42
# If no filter, select all tests
selected = not (test_name_prefix_filter or test_attr_regex_filters)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this feels a bit twisted..

could you refactor the selection logic out into a util function? basically:

def _match_test_selection(test, name_prefix, attr_regex) -> bool:
   if match_prefix():
       return True
   if match_regex():
       return True
   return False

then for the test filtering for loop:


select_all = not (test_name_prefix_filter or test_attr_regex_filters)

for test in Tests:
    if not select_all and not _match_test_selection(test, ...):
       continue
    
    # do the extra smoke test / frequency / filtering here.

]

# Test filter by prefix alone
filtered = self._filter_names_smoke(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can we rename _filter_names_smoke to just _filter_names?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

khluu added 3 commits August 19, 2025 09:23
p
Signed-off-by: kevin <kevin@anyscale.com>
p
Signed-off-by: kevin <kevin@anyscale.com>
p
Signed-off-by: kevin <kevin@anyscale.com>
@khluu khluu requested a review from aslonnie August 19, 2025 09:24
Copy link
Collaborator

@aslonnie aslonnie left a comment

Choose a reason for hiding this comment

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

have you manually tried if it works?

@aslonnie
Copy link
Collaborator

could you manually test it for one last time before merging?

  • test backwards compatibility: if the regex still works
  • test if the new prefix feature works.

@aslonnie aslonnie self-requested a review August 21, 2025 00:08
@aslonnie aslonnie added the go add ONLY when ready to merge, run all tests label Aug 21, 2025
@aslonnie
Copy link
Collaborator

could you manually test it for one last time before merging?

  • test backwards compatibility: if the regex still works
  • test if the new prefix feature works.

and post the link here?

Copy link
Collaborator

@aslonnie aslonnie left a comment

Choose a reason for hiding this comment

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

synced offline. waiting for proof that it works. and @khluu also says it requires some more changes.

khluu added 3 commits August 25, 2025 18:02
p
Signed-off-by: kevin <kevin@anyscale.com>
p
Signed-off-by: kevin <kevin@anyscale.com>
p
Signed-off-by: kevin <kevin@anyscale.com>
@khluu khluu requested a review from aslonnie August 25, 2025 23:32
@khluu
Copy link
Contributor Author

khluu commented Aug 25, 2025

@aslonnie I made some changes to rename regex filter with just test filters to accommodate for prefix filter as part of it. Can you help do another round of review?

@khluu
Copy link
Contributor Author

khluu commented Aug 25, 2025

I ran a test with prefix filter tune_scalability_durable and it was able to do the filtering correctly. I'll look into the test failures (both premerge and release test)

Copy link
Collaborator

@aslonnie aslonnie left a comment

Choose a reason for hiding this comment

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

let me know when it is ready.

Signed-off-by: kevin <kevin@anyscale.com>
@khluu
Copy link
Contributor Author

khluu commented Aug 27, 2025

@aslonnie It's ready now.. https://buildkite.com/ray-project/release/builds/55314 as proof that it works with prefix tune_scalability_durable

@khluu khluu requested a review from aslonnie August 27, 2025 19:24
@aslonnie aslonnie merged commit 777370e into master Aug 27, 2025
5 checks passed
@aslonnie aslonnie deleted the khluu/filter_test branch August 27, 2025 22:58
tohtana pushed a commit to tohtana/ray that referenced this pull request Aug 29, 2025
- This filter test func can now use either or both of name prefix filter
or regex filter. If both are used at the same time, test matches either
of the filter is accepted

---------

Signed-off-by: kevin <kevin@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
tohtana pushed a commit to tohtana/ray that referenced this pull request Aug 29, 2025
- This filter test func can now use either or both of name prefix filter
or regex filter. If both are used at the same time, test matches either
of the filter is accepted

---------

Signed-off-by: kevin <kevin@anyscale.com>
Signed-off-by: Masahiro Tanaka <mtanaka@anyscale.com>
gangsf pushed a commit to gangsf/ray that referenced this pull request Sep 2, 2025
- This filter test func can now use either or both of name prefix filter
or regex filter. If both are used at the same time, test matches either
of the filter is accepted

---------

Signed-off-by: kevin <kevin@anyscale.com>
Signed-off-by: Gang Zhao <gang@gang-JQ62HD2C37.local>
sampan-s-nayak pushed a commit to sampan-s-nayak/ray that referenced this pull request Sep 8, 2025
- This filter test func can now use either or both of name prefix filter
or regex filter. If both are used at the same time, test matches either
of the filter is accepted

---------

Signed-off-by: kevin <kevin@anyscale.com>
Signed-off-by: sampan <sampan@anyscale.com>
jugalshah291 pushed a commit to jugalshah291/ray_fork that referenced this pull request Sep 11, 2025
- This filter test func can now use either or both of name prefix filter
or regex filter. If both are used at the same time, test matches either
of the filter is accepted

---------

Signed-off-by: kevin <kevin@anyscale.com>
Signed-off-by: jugalshah291 <shah.jugal291@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Issues that should be addressed in Ray Core devprod go add ONLY when ready to merge, run all tests release-test release test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants