Skip to content

[Python] Update Direct inferencePostCommitIT requirements and Gradle tasks for Python 3.13 - #41648

Open
damccorm wants to merge 1 commit into
users/damccorm/py313-inference-4-enrichmentfrom
users/damccorm/py313-inference-5-gradle-reqs
Open

damccorm wants to merge 1 commit into
users/damccorm/py313-inference-4-enrichmentfrom
users/damccorm/py313-inference-5-gradle-reqs

Conversation

@damccorm

@damccorm damccorm commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Part of #41652 (stack: https://github.com/apache/beam/stack/41650).

Stack 5/6 — Updates Direct inferencePostCommitIT dependency constraints and Gradle task configs for Python 3.13:

  • tensorflow_tests_requirements.txt: Use Python-version markers (tf-keras>=2.16.0 + tensorflow>=2.16.0,<2.22 on Python >= 3.12, preserving keras<3.0.0 + tensorflow>=2.12.0,<2.16 on Python < 3.12 for the Python 3.11 Dataflow cost benchmarks).
  • torch_tests_requirements.txt & huggingface_tests_requirements.txt: Cap torch>=2.3.0,<2.12.0 (matching setup.py and tox.ini) so torch>=2.12 does not pull triton>=3.7, which aborts with an LLVM option registration collision when imported alongside TensorFlow in the shared virtualenv; add tensorflow>=2.12.0,<2.22 and tf-keras>=2.16.0; python_version >= '3.12' to huggingface_tests_requirements.txt.
  • sdks/python/test-suites/direct/common.gradle:
    • Remove the obsolete pip install 'scikit-learn<1.2.0' doFirst step in sklearnInferenceTest (fails to build on Python 3.13; apache-beam[test] already provides scikit-learn<1.8.0).
    • Export TF_USE_LEGACY_KERAS=1 in tensorflowInferenceTest so legacy TF2 SavedModels load under TensorFlow 2.16+.
    • Install enrichment_tests_requirements.txt (redis>=5.0.0,<6) in testcontainersTest (matching dataflow:mockAPITests, needed since redis was moved to an optional extra in split redis into extra #36772).
    • Give each direct inference/enrichment Gradle task a distinct JUnit suite name so per-task XML reports no longer overwrite pytest_postCommitIT-direct-py*.xml.

Verification

@codecov

codecov Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.04%. Comparing base (5f99f26) to head (e148a5d).

Additional details and impacted files
@@                                Coverage Diff                                @@
##             users/damccorm/py313-inference-4-enrichment   #41648      +/-   ##
=================================================================================
- Coverage                                          58.04%   58.04%   -0.01%     
  Complexity                                          2844     2844              
=================================================================================
  Files                                               1210     1210              
  Lines                                             173284   173284              
  Branches                                            2329     2329              
=================================================================================
- Hits                                              100587   100581       -6     
- Misses                                             69987    69993       +6     
  Partials                                            2710     2710              
Flag Coverage Δ
python 80.67% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@damccorm

Copy link
Copy Markdown
Contributor Author

stop reviewer notifications

…tasks for Python 3.13

- tensorflow_tests_requirements.txt: use Python-version markers for tf-keras
  and tensorflow>=2.16,<2.22 on Python >= 3.12 while preserving keras<3 and
  tensorflow<2.16 on Python < 3.12.
- torch_tests_requirements.txt & huggingface_tests_requirements.txt: cap
  torch<2.12.0 to prevent triton>=3.7 LLVM option registration collision when
  imported alongside TensorFlow, and add tensorflow/tf-keras bounds for HF ITs.
- sdks/python/test-suites/direct/common.gradle: remove obsolete
  scikit-learn<1.2.0 downgrade, export TF_USE_LEGACY_KERAS=1 for
  tensorflowInferenceTest, install enrichment_tests_requirements.txt (redis) in
  testcontainersTest, and give each direct inference/enrichment task a distinct
  JUnit suite name so per-task XML reports are not overwritten.
@damccorm
damccorm force-pushed the users/damccorm/py313-inference-5-gradle-reqs branch from f5785ad to e148a5d Compare November 24, 2026 20:08
@damccorm
damccorm marked this pull request as ready for review November 24, 2026 20:09
@github-actions

Copy link
Copy Markdown
Contributor

Stopping reviewer notifications for this pull request: requested by reviewer. If you'd like to restart, comment assign set of reviewers

@jrmccluskey jrmccluskey left a comment

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.

LGTM, just two observations in related code

"test_opts": testOpts,
"suite": "postCommitIT-direct-py${pythonVersionSuffix}",
"suite": "tensorflowInferenceTest-direct-py${pythonVersionSuffix}",
"collect": "uses_tf and it_postcommit" ,

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.

Not introduced here, but it looks like we have a uses_tensorflow label as well as a uses_tf label? Looks like a distinction between TFX and TensorFlow, probably worth a refactor later

doFirst {
exec {
executable 'sh'
args '-c', ". ${envdir}/bin/activate && pip install -r $requirementsFile"

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.

This is another place we could consider using uv to catch dependency mismatches more consistently, but probably to do some more experimenting before full-committing there

@github-actions github-actions Bot left a comment

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.

📋 Review Summary

This PR cleanly updates the Direct Runner inferencePostCommitIT dependency constraints and Gradle task configurations to support Python 3.13 while preserving compatibility for Python < 3.12 benchmarks. The changes align dependency bounds with setup.py and tox.ini, resolve Keras 3 / Triton compatibility issues, and prevent JUnit XML report overwrites across sub-tasks.

🔍 General Feedback

  • Dependency version markers and upper bounds (torch<2.12.0, tensorflow<2.22, and tf-keras>=2.16.0 on Python >= 3.12) are consistent with the rest of the Python SDK test configuration.
  • Assigning distinct suite names per Gradle task in sdks/python/test-suites/direct/common.gradle is a good fix to prevent pytest_*.xml test report collisions when running inferencePostCommitIT.

💡 Tip: Comment /gemini review on this pull request to trigger a new Gemini code review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python size/s S: 10-49 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants