HyukjinKwon opened a new pull request, #756:
URL: https://github.com/apache/spark-connect-rust/pull/756
### What changes were proposed in this pull request?
The shared `Recorder` of the ML API cases (`python/tests/_ml_api_cases.py`)
rounds the floats of a recorded value to 9 decimals by default, because CI's
Linux Spark server and a local one differ in the last bits of some doubles. Its
`_rounded` recursed only into lists and ML vectors, though. A float inside a
`Row`, a tuple, a dict or a `SparseMatrix` stayed unrounded and was recorded by
its repr:
- the recommendations of `ALS.recommendForAll*`, which are Rows of a float
rating inside a DataFrame row;
- the metrics in the metadata dicts of the validators' saves.
Each case that met one rounded the value itself, or was exposed to that
drift.
This PR:
- makes `_rounded` recurse into a list, a tuple, a `Row` (keeping its
fields), a dict, and an ML vector or matrix (keeping its class and layout,
`SparseMatrix` included), so each value keeps its type and the shape of its
repr;
- makes the Recorder the only place that rounds. With `rounded=False`, a
bare float was still rounded to 9 decimals, and some cases rounded their own
floats: the validators' metrics, and the cluster centers of KMeans and
BisectingKMeans. Now `rounded=False` records every float exactly, and the cases
record their values as they are;
- makes the docstrings say that the rounding is absolute, to the nearest
1e-9.
The goldens are recaptured on official PySpark 4.3.0 with the new Recorder.
Only the ones whose records changed are updated.
### Why are the changes needed?
So that the recorded ML API cases don't depend on the last bits of a float
wherever it sits in a value, and CI's server and a local one record the same
goldens.
### Does this PR introduce _any_ user-facing change?
No, tests only.
### How was this patch tested?
- Every Recorder golden is recaptured on official PySpark 4.3.0
(`sc://localhost:15076`), each twice, and the two captures are byte-identical:
`ml_api`, `logistic_api`, `tree_api`, `misc_api`, `regression_api`,
`clustering_api`, `evaluation_api`, `feature_api` and `fpm_recommendation_api`.
Two of them change: `ml_api` (the metrics in the metadata of the validators'
saves, 2 leaves) and `fpm_recommendation_api` (the ratings of the ALS
recommendations, 14 leaves). The other seven recapture byte-identical,
`clustering_api` included, on the current master that has its new `computeCost`
cases.
- A checker walks each old and new golden together. Their key sets are
equal, and each leaf that differs is equal once every float literal in both is
rounded to 9 decimals, also inside repr strings, with -0.0 as 0.0. So every
change is rounding only.
- On this client, CI's offline suite passes (5806 passed), and so do the
live suites of every family,
`test_{ml_api,logistic_api,tree_api,misc_api,regression_api,clustering_api,evaluation_api,feature_api,fpm_recommendation_api}_e2e.py`
(185 passed).
- `ruff check` and `ruff format --check` are clean.
### 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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]