8000 [POC] fix test_metrics by abrarsheikh · Pull Request #54037 · ray-project/ray · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[POC] fix test_metrics #54037

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 24, 2025
Merged

[POC] fix test_metrics #54037

merged 2 commits into from
Jun 24, 2025

Conversation

abrarsheikh
Copy link
Contributor

Why are these changes needed?

Related issue number

Checks

  • I've signed off every commit(by using the -s flag, i.e., git commit -s) in this PR.
  • I've run scripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed for https://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it in doc/source/tune/api/ under the
      corresponding .rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures at https://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

Signed-off-by: abrar <abrar@anyscale.com>
@Copilot Copilot AI review requested due to automatic review settings June 24, 2025 06:44
@abrarsheikh abrarsheikh requested a review from a team as a code owner June 24, 2025 06:44
@abrarsheikh abrarsheikh added the go add ONLY when ready to merge, run all tests label Jun 24, 2025
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR aims to fix test metrics and update request routing logic.

  • In tests, a timeout is added and an assertion is now used to ensure the metric is present immediately.
  • In the router, the dynamic replica selection is temporarily replaced with a hardcoded selection of the first replica.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
python/ray/serve/tests/test_metrics.py Updated HTTP calls to include timeouts and assertions in test functions
python/ray/serve/_private/router.py Changed replica selection by hardcoding the first replica from the available replicas
Comments suppressed due to low confidence (1)

python/ray/serve/_private/router.py:628

  • Hardcoding the selection of the first replica may lead to non-deterministic behavior and bypasses the intended replica selection logic. It would be preferable to enhance the replica selection process rather than simplifying it to the first available replica.
        r = list(self.request_router._replicas.values())[0]

Comment on lines +195 to +196
assert name in metrics
return True
Copy link
Preview
Copilot AI Jun 24, 2025

Choose a reason for hiding this comment

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

Using an assertion here causes the test to fail immediately instead of waiting for the metric to become available through wait_for_condition. Consider returning a boolean check to allow the wait to work as intended.

Suggested change
assert name in metrics
return True
if name in metrics:
return True
return False

Copilot uses AI. Check for mistakes.

Signed-off-by: abrar <abrar@anyscale.com>
@zcin zcin merged commit 90933ba into master Jun 24, 2025
5 checks passed
@zcin zcin deleted the test_metrics-abrar-flaky_test branch June 24, 2025 16:36
minerharry pushed a commit to minerharry/ray that referenced this pull request Jun 27, 2025
## Why are these changes needed?

Fix test_metrics

---------

Signed-off-by: abrar <abrar@anyscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go add ONLY when ready to merge, run all tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0