This is an automated email from the ASF dual-hosted git repository.
HyukjinKwon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark-connect-rust.git
The following commit(s) were added to refs/heads/master by this push:
new c9c73ea7 [SPARK-61325][CONNECT][INFRA][TESTS] Pin the Python hash seed
of the official Connect test runs so that the default pyspark.ml seeds are the
same in every run
c9c73ea7 is described below
commit c9c73ea73cc812224da47b466f60fd4e26ac7a4e
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Tue Nov 10 10:21:53 2026 +0900
[SPARK-61325][CONNECT][INFRA][TESTS] Pin the Python hash seed of the
official Connect test runs so that the default pyspark.ml seeds are the same in
every run
### What changes were proposed in this pull request?
[SPARK-61325](https://issues.apache.org/jira/browse/SPARK-61325):
`scripts/run_official_tests.py` sets `PYTHONHASHSEED=0` for its test processes,
in both modes (through the Rust transport and against the drop-in).
### Why are the changes needed?
The default seed of a `pyspark.ml` estimator is `hash(type(self).__name__)`
(`HasSeed`), and Python randomizes the hash of a str per process. So the random
k-fold split of `CrossValidator` differs per run. In about 7% of the runs, the
official `test_crossvalidator_with_random_forest_classifier`
(`pyspark/ml/tests/connect/test_parity_tuning.py`: 6 rows, 3 folds, no seed)
trains a fold on label 0 only, and the evaluation fails with `requirement
failed: rawPredictionCol vectors must have [...]
This comes from the test's randomness, not from a client:
- The `rand(seed)` split of the test's 6 rows, as `CrossValidator._kFold`
computes it, trains a fold on label 0 only for 22 of the seeds 0 to 299 (19,
66, 97, 102, ...).
- `CrossValidator(..., seed=19)` and `seed=66` on the test's data fail with
that error on official PySpark 4.3.0 and on the drop-in alike, and seed 18
passes on both.
With `PYTHONHASHSEED=0`, the default seed of `CrossValidator` is
`-3087263388934076904` in every run, and that split passes on both clients.
### Does this PR introduce _any_ user-facing change?
No, CI only.
### How was this patch tested?
Against a local Spark 4.3.0 Connect server:
- `run_official_tests.py --dropin --only
pyspark.ml.tests.connect.test_parity_tuning`, three runs: 7 passed each.
- `run_official_tests.py --only
pyspark.ml.tests.connect.test_parity_tuning` (through the transport), two runs:
7 passed each.
- The `CrossValidator` seed checks above, on official PySpark 4.3.0 and on
the drop-in.
- `python -m unittest discover -s scripts/tests`: OK.
It merges cleanly with #443, which edits the same function.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Opus 5.5
This pull request and its description were written by Isaac.
Closes #450 from HyukjinKwon/SPARK-61325-official-tests-hash-seed.
Authored-by: Hyukjin Kwon <[email protected]>
Signed-off-by: Hyukjin Kwon <[email protected]>
---
scripts/run_official_tests.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/run_official_tests.py b/scripts/run_official_tests.py
index 916f2dfe..fa68f75f 100755
--- a/scripts/run_official_tests.py
+++ b/scripts/run_official_tests.py
@@ -241,6 +241,12 @@ def run_ours(
dropin=False,
):
env = dict(os.environ)
+ # A fixed hash seed, as the default seed of a pyspark.ml estimator is
+ # hash(type(self).__name__) (HasSeed): with a random one, the random
k-fold split of
+ # CrossValidator differs per run, and in about 7% of the runs the official
+ # test_crossvalidator_with_random_forest_classifier trains a fold on one
label and fails,
+ # for the reference client as for ours.
+ env["PYTHONHASHSEED"] = "0"
env["SPARK_CONNECT_TESTING_REMOTE"] = remote
env["SPARK_TESTING"] = "1"
if dropin:
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]