Repository navigation
Conversation
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR makes the number of pytest-xdist workers configurable via PYTEST_XDIST_WORKERS (defaulting to 6) in sdks/python/scripts/run_pytest.sh and reduces the worker count to 2 for the py311-tft-121 tox environment to mitigate OOM evictions. The implementation is clean, minimal, and backward-compatible across existing test environments.
🔍 General Feedback
- Inheriting
{[testenv]setenv}in[testenv:py311-tft-121]properly preserves global test environment variables while scoping the worker reduction specifically to the memory-intensive TFT test suite. - Using
${PYTEST_XDIST_WORKERS:-6}inrun_pytest.shmaintains the existing default concurrency for all other test suites without affecting the sequentialno_xdisttest execution pass.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41778 +/- ##
=========================================
Coverage 58.91% 58.91%
Complexity 2346 2346
=========================================
Files 1136 1136
Lines 171138 171144 +6
Branches 1567 1567
=========================================
+ Hits 100819 100824 +5
- Misses 67762 67763 +1
Partials 2557 2557
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…t PYTEST_XDIST_WORKERS workaround
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR switches beam_PostCommit_Python_Dependency from main to highmem self-hosted runners to prevent OOM/pod evictions when running the heavy ML dependency tox suites (py311-tft-121, PyTorch, TensorFlow, etc.). The change is minimal, well-justified by recent CI failure evidence, and aligns with existing memory-intensive Python workflows in the repository.
🔍 General Feedback
- The single-line workflow configuration update (
runs-on: [self-hosted, ubuntu-24.04, highmem]) matches the established pattern inbeam_PreCommit_Python_Coverage.ymland other resource-heavy Python workflows. - No issues found; this looks ready to merge once the verification run completes.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
…nstead of switching to highmem
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR adds an opt-in CLEANUP_TOX_ENV=1 mechanism to sdks/python/scripts/run_tox.sh to delete individual target/.tox-$TOX_ENVIRONMENT working directories after tox finishes, and enables it in beam_PostCommit_Python_Dependency.yml. This cleanly resolves the ephemeral-storage pod evictions caused by accumulating 23 heavy ML virtualenvs sequentially during the dependency postcommit suite.
🔍 General Feedback
- The cleanup in
run_tox.shproperly preserves thetoxexit code and guardsrm -rfwith a non-emptyENV_NAMEcheck. - Because
pytest_*.xmlJUnit reports are written outsidetarget/.tox-*andtoxis invoked with--recreate, removing the finished environment directory is safe and does not affect test result reporting or local developer workflows.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
| env: | ||
| DEVELOCITY_ACCESS_KEY: ${{ secrets.BEAM_DEVELOCITY_ACCESS_KEY }} | ||
| HF_INFERENCE_TOKEN: ${{ secrets.HF_INFERENCE_TOKEN }} | ||
| CLEANUP_TOX_ENV: "1" |
There was a problem hiding this comment.
I think this should be set by tasks that run into this problem, not at the workflow level. Otherwise if another suite adopts the same task, it will run into the same problem
There was a problem hiding this comment.
Done in af36f38: removed CLEANUP_TOX_ENV: "1" from .github/workflows/beam_PostCommit_Python_Dependency.yml, added optional task-level cleanupToxEnv support to project.ext.toxTask in BeamModulePlugin.groovy (respecting an explicit CLEANUP_TOX_ENV override if set), and enabled it.ext.cleanupToxEnv = true on all postCommitPyDep dependency tasks in sdks/python/test-suites/tox/py311/build.gradle and sdks/python/test-suites/tox/py314/build.gradle so any suite adopting those tasks gets cleanup automatically. Re-triggered beam_PostCommit_Python_Dependency.yml for verification.
|
/gemini review |
There was a problem hiding this comment.
📋 Review Summary
This PR prevents pod ephemeral storage exhaustion in PostCommit Python Dependency suites by adding an opt-in CLEANUP_TOX_ENV mechanism to run_tox.sh and BeamModulePlugin.groovy, and enabling it for all postCommitPyDep tasks in py311 and py314. The implementation is clean, preserves exit codes and pytest JUnit XML artifacts, and encapsulates the cleanup configuration at the Gradle task level.
🔍 General Feedback
- Moving the
cleanupToxEnvconfiguration from the GitHub Actions workflow level to the Gradle task definitions inBeamModulePlugin.groovyandbuild.gradleensures any suite or invocation running these tasks benefits from the cleanup while still allowing explicitCLEANUP_TOX_ENVenvironment overrides. - Please note that the PR description under Summary and Fix still mentions setting
CLEANUP_TOX_ENV: "1"in.github/workflows/beam_PostCommit_Python_Dependency.ymlfrom an earlier iteration; consider updating the PR description to match the current Gradle-based approach.
💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.
Note: this PR was auto-generated by tooling. Before moving it out of draft, the author has done a full review of the PR, specifically evaluating it on the following criteria:
Full details of the methodology of generation and review can be found here - https://docs.google.com/document/d/14lj7ECVov4T4EdwmIzNlWrRGE3lLDMOwX5xUMGzaLoc/edit?usp=sharing
If you have concerns with the PR or with the underlying methodology used to generate this, please comment below - they will be addressed by the author not the tooling :)
Summary
Removes each recreated
target/.tox-$TOX_ENVIRONMENTworkdir aftertoxfinishes whenCLEANUP_TOX_ENV=1, and configurescleanupToxEnv = trueat the GradletoxTasklevel for allpostCommitPyDepdependency tasks insdks/python/test-suites/tox/py311/build.gradleandsdks/python/test-suites/tox/py314/build.gradleso sequential ML dependency virtualenvs do not accumulate and exhaust pod ephemeral storage (regardless of which workflow or suite runs those tasks).Recent Occurrences
2026-12-01T11:00:21Z):beam_PostCommit_Python_Dependency (3.11)lost communication duringtestPy311tft-121onmain.2026-11-30T21:00:20Z):beam_PostCommit_Python_Dependency (3.11)lost communication duringtestPy311tft-121onmain.2026-11-29T00:34:24Z):beam_PostCommit_Python_Dependency (3.11)lost communication duringtestPy311tft-121onmain.2026-11-27T01:03:28Z):beam_PostCommit_Python_Dependency (3.11)lost communication duringtestPy311tft-121onmain.testPy311tft-121.PYTEST_XDIST_WORKERS=2(46452596108 still evicted intestPy311tft-121) and switching tohighmemrunners (46504976877 evicted twice in a row at ~57m including the 40m heartbeat timeout on both attempt 1 and attempt 2).Root Cause
sdks/python/scripts/run_tox.shisolates each tox environment undertarget/.tox-$TOX_ENVIRONMENTand always runstox run --recreate, so finished workdirs are never reused (andpytest_*.xmlreports are written tosdks/python/pytest_*.xmloutsidetarget/.tox-*). However, nothing deletes finishedtarget/.tox-*directories between Gradle tasks. Duringbeam_PostCommit_Python_Dependency (3.11), 26 dependency environments accumulate sequentially on the same pod (including PyTorch, TensorFlow, TFT 1.21, Transformers, ONNX, XGBoost, Embeddings, TFHubEmbeddings, Pandas, and 10 PyArrow versions), eventually triggering kubelet ephemeral-storage pod eviction.Fix
sdks/python/scripts/run_tox.sh, deletetarget/${ENV_NAME}aftertoxexits (preserving$exit_code) whenCLEANUP_TOX_ENV=1is set.buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy, add optionalcleanupToxEnvsupport (task.ext.cleanupToxEnv, defaulting tofalse) toproject.ext.toxTask, settingCLEANUP_TOX_ENV=1on theproject.execenvironment when enabled (while respecting an explicitCLEANUP_TOX_ENVenvironment override such asCLEANUP_TOX_ENV=0for local debugging).sdks/python/test-suites/tox/py311/build.gradleandsdks/python/test-suites/tox/py314/build.gradle, configureit.ext.cleanupToxEnv = trueon everypostCommitPyDepdependency task so any workflow or suite invoking those tasks gets automatic cleanup without workflow-level env configuration.Verification
mainrunners): https://github.com/apache/beam/actions/runs/46536218771af36f386996): https://github.com/apache/beam/actions/runs/46901949521Build/CI/test-script-only change; no production SDK code is modified.