Upgrade TFMA to TF 2.21.0 and Added Python 3.12/3.13 support#522
Open
vkarampudi wants to merge 20 commits intotensorflow:masterfrom
Open
Upgrade TFMA to TF 2.21.0 and Added Python 3.12/3.13 support#522vkarampudi wants to merge 20 commits intotensorflow:masterfrom
vkarampudi wants to merge 20 commits intotensorflow:masterfrom
Conversation
- Refactored core test matchers to class-based architecture for pickling stability on Python 3.13. - Updated dependencies: TF 2.21.0, Protobuf 6.31.1+, Bazel 7.4.1, PyArrow >14. - Dropped support for Python 3.9 (Minimum supported 3.10). - Updated GitHub Actions to support Python 3.10-3.13. - Consolidated apache-beam constraints and restored TFX-BSL fork for CI validation. - Fixed various environment-specific regressions (numpy scalar conversion, extractors mutation).
- Replaced tag-based archives with immutable commit-based archives for TensorFlow v2.21.0 and Protobuf v31.1. - Added SHA256 checksum verification to ensure build integrity.
- Fixed E402 (Module level import not at top of file) in evaluator tests. - Resolved trailing whitespace in multiple modules. - Standardized quotes and formatting in setup.py. - Corrected import order in SQL extractor modules. - Fixed class definitions and removed redundant object inheritance.
- Restored 'types' import in metrics_plots_and_validations_evaluator_test.py (fixed F821). - Applied final formatting fixes and removed trailing whitespace across test suites. - Synchronized extraction and evaluation modules with ruff-standard formatting.
- Consolidated API imports in evaluator tests. - Removed unused metric imports. - Standardized whitespace after class definitions in all test suites. - Fixed indentation and formatting in Attributions and Metrics check functions. - Added necessary blank lines for PipelineOptions imports.
- Auto-fixed trailing whitespace in rouge_test.py. - Refined indentation in evaluation metric checks. - Standardized class definition spacing in extraction modules. - Applied missing blank lines in setup.py and utility tests.
- Applied consistent spacing in extractors and metrics. - Standardized indentation across test suites. - Re-synchronized all formatting with strict CI standards.
- Broadened pandas constraint to >=1.0,<3 in setup.py. - This unblocks the CI environment initialization by allowing pandas 2.x, which is required by the tfx-bsl testing fork.
- Refactored scalar extraction to use .item() instead of float(ndarray). - Implemented safe division in AUC/PR AUC metrics. - Fixed SubKey(k=k) indexing logic regression. - Restored necessary protobuf generated files for environment stability. - Verified fixes with full test suite pass.
- Fix scalar conversion issues in aggregation and flip metrics. - Fix batching bug in _BooleanFlipCountsCombiner. - Harden confusion matrix and calibration metrics against zero division. - Fix rouge metric ValueError. - Fix missing numpy imports across metrics. - Add regression test for array-like inputs in flip_metrics_test.py.
…ession in model_util_test.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR adds official support for Python 3.12 and 3.13, stabilizes the codebase for Python 3.13, and ensures compatibility with NumPy 2.0 (validating on NumPy 1.25+). It resolves critical architectural pickling failures in Apache Beam pipelines, addresses strict scalar conversion rules in NumPy 2.0, and fixes several functional regressions in tests.
Detailed Changes
1. Core Architecture & Pickling Stability (Python 3.12 & 3.13 Support)
rouge_test.py,stats_test.py, model_util_test.py).PicklingErrororRuntimeError: Unable to pickle fnduring distributed execution withPrismRunneron Python 3.13. Python 3.13 has stricter rules regarding serialization of functions that capture surrounding state (likeselfreferring to the test instance).kind='stable'sort inmetric_util.top_k_indices.2. NumPy 2.0 Compatibility
float(ndarray)withnp.asarray(x).item()across the metrics library (e.g.,aggregation.py,flip_metrics.py,ndcg.py).TypeError: only 0-dimensional arrays can be converted to Python scalarsorAttributeErrorwhen trying to convert arrays to scalars. NumPy 2.0 strictly enforces that only true scalars or 0-dimensional arrays can be cast to Python scalars this way.np.dividewithwhereclauses in confusion matrix metrics.RuntimeWarning: invalid value encountered in divide(division by zero) when predictions or labels were zero for certain slices.poisson(1, 1)inpoisson_bootstrap.py.TypeErrorin NumPy 2.0 wherepoissonexpected different arguments or behavior changed when size was provided in a way that wasn't expected.3. Functional Fixes & Regressions
false_omission_rateinbinary_confusion_matrices.pyto return NaN when undefined, ensuring it's a float array.confusion_matrix_plot_test.pyandscore_distribution_plot_test.pywhere tests expected NaN but got valid float representations that didn't match the expected proto structure due to undefined states.NotFoundErrorin model_eval_lib_test.py by ensuring directories exist before writing files usingtf.io.gfile.makedirs./tmp/absl_testingdid not exist when trying to write test results.SubKey(k=k)selection logic inmetric_util.pyby explicitly passingsort=True.4. Dependency & Infrastructure
">=3.10,<3.14".Verification Results
All unit tests have been verified to pass in the target python environment (Python 3.13, 3.12, 3.11, 3.10 & TF 2.21.0). Specific edge case failures (e.g., weight mismatches in
rouge_test.pyandstats_test.py) were investigated and confirmed to be expected negative test behaviors asserting specific error messages.