Repository navigation
feat: support Spark 4 and numpy 2 - #83
Open
ConorWorthington wants to merge 1 commit into
Open
ConorWorthington wants to merge 1 commit into
ConorWorthington wants to merge 1 commit into
Conversation
Relax dependency bounds to pyspark>=3.4.0,<5.0.0 and numpy>=1.22.0 (no upper bound), fixing installs on Databricks runtimes that ship numpy 2. Spark 4 enables ANSI mode by default, under which division/modulo by zero and out of bounds element_at raise instead of returning null. Guard these explicitly so results match Spark 3 and the Keras layers: - Divide, CosineSimilarity, PairwiseCosineSimilarity: zero divisor -> 0.0 - Modulo: zero divisor -> null - SubStringDelimAtIndex: out of bounds index -> defaultValue - ListMedian: empty list -> nanFillValue Tests: - Add test_ansi_mode.py covering the above with ANSI on and off. - Fix test helper scalar conversion for numpy 2.5. - Patch the concrete DataFrame class in the checkpoint test, since pyspark.sql.DataFrame is abstract in Spark 4. - Check JIT-incompatible layers via experimental_get_compiler_ir, avoiding a TF 2.21 abort in the XLA compilation cache on repeated failed compiles of string ops. CI: add pyspark 4.0.1 lane, set up Java 17, keep a numpy 1.26 lane. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
georyetti
approved these changes
Oct 30, 2026
This branch has not been deployed
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.
Relax dependency bounds to pyspark>=3.4.0,<5.0.0 and numpy>=1.22.0 (no upper bound), fixing installs on Databricks runtimes that ship numpy 2.
Spark 4 enables ANSI mode by default, under which division/modulo by zero and out of bounds element_at raise instead of returning null. Guard these explicitly so results match Spark 3 and the Keras layers:
Tests:
CI: add pyspark 4.0.1 lane, set up Java 17, keep a numpy 1.26 lane.
Description
Provide a short description of the PR changes.
The below checklists come from the docs page on adding new transformers here
Keras Layer Checklist
Verify that:
_callmethod has been implemented in the new layer.compatible_dtypesproperty is defined in the new layer.@tf.keras.utils.register_keras_serializable(package=kamae.__name__).name,input_dtype, andoutput_dtypeas arguments to the constructor and that this is passed to the super constructor.get_configmethod.layersdirectory.Spark Transformer/Estimator Checklist
Verify that:
__init__andsetParamsmethods.Paramsclass here.compatible_dtypesproperty has been implemented to specify the input/output data types that my transformer/estimator supports.get_tf_layermethod.transformers/estimatorsdirectory.Finally, please verify that: