HyukjinKwon opened a new pull request, #699:
URL: https://github.com/apache/spark-connect-rust/pull/699
### What changes were proposed in this pull request?
**Stacked on the validators PR (#698), itself on #690**: please review the
last commit.
Three fixes of the PyO3 base of the native ML classes, which the area PRs
found (forked-0a's feature and fpm conversions):
- **The defaults that PySpark's constructor fetches of the server.**
Official 4.3.0's `StopWordsRemover.__init__` reads two defaults of the ML
helper over Spark Connect (`invoke_helper_attr`): `stopWords`
(`stopWordsRemoverLoadDefaultStopWords("english")`) and `locale`
(`stopWordsRemoverGetDefaultOrUS`, the server JVM's locale). Without a session
it raises an `AssertionError`.
- `scripts/capture_ml_api_golden.py` constructs such a class of a session
(`SPARK_REMOTE`) and records those defaults as the fetch, `{"server_default":
[attr, args...]}` (`SERVER_DEFAULTS`). `ml_api.json` and `ml_params.json` now
have StopWordsRemover's defaults, the static `caseSensitive=False` and
`outputCol` among them.
- `params_api::server_defaults(py, class)` fetches them of the active
session, for a native constructor to hold as its own defaults (as `_setDefault`
of them). It raises PySpark's `AssertionError` without a session. A server
default that an object does not hold is fetched when it is read.
- The native StopWordsRemover takes them in its own PR (forked-0a's
feature transformers, #693).
- **Column arguments of the members of a model.** A Column argument, even
`F.lit(1.0)`, now raises PySpark's `UNSUPPORTED_DATA_TYPE`, as
`pyspark.ml.connect.serialize` raises it; a Column of a literal was sent as the
literal.
- **Params-only native classes** (PrefixSpan, which neither fits, transforms
nor evaluates) are registered as virtual subclasses of
`pyspark.ml.param.Params`, as the others are of their base classes.
### Why are the changes needed?
The native classes are to follow `pyspark.ml`: StopWordsRemover's defaults
come from the server in PySpark, the members of a model take the values that
PySpark sends, and `isinstance(PrefixSpan(), Params)` holds in PySpark.
### Does this PR introduce _any_ user-facing change?
Yes: a Column argument of a member of a native model
(`model.predict(F.lit(1.0))`) raises PySpark's `UNSUPPORTED_DATA_TYPE` instead
of sending the literal. The other changes take effect in the classes that use
them.
### How was this patch tested?
- A new live case of `_ml_api_cases.py`, `predict_column`, against the
golden recaptured on official pyspark-client 4.3.0 (the other cases are
unchanged); `test_ml_api_offline.py` and `test_ml_api_e2e.py` pass on ours and
on official.
- `server_defaults`, by hand, through a probe of a local build (not part of
this PR): a bare `AssertionError` without a session, and with one the `locale`
(`en_US`) and the 181 English stop words that official's constructor fetches.
- The API golden recaptured with a session changes StopWordsRemover only.
### 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]