HyukjinKwon opened a new pull request, #810:
URL: https://github.com/apache/spark-connect-rust/pull/810

   ### What changes were proposed in this pull request?
   
   A follow-up of #784 (SPARK-61865), from a round-2 review of the native ML 
classes against PySpark 4.3.0. Each item was probed on both clients.
   
   **1. Class methods and static methods are PySpark's functions.**
   - The methods of the native ML classes are PySpark's functions (`_synced`): 
they have PySpark's qualified name, module, docstring and signature, so a call 
that does not bind raises PySpark's message.
   - Their class methods and static methods were PyO3's, of other qualified 
names, no module, and signatures such as `(cls, /)`:
     - `read`, of `JavaMLReadable.read` and of the `try_remote_read` of a 
Pipeline or a validator;
     - `StringIndexerModel.from_labels` and `from_arrays_of_labels`, and 
`CountVectorizerModel.from_vocabulary`;
     - `StopWordsRemover.loadDefaultStopWords`.
   - So `LogisticRegression.read(1)` raised `LogisticRegression.read() takes no 
arguments (1 given)`, where PySpark raises `JavaMLReadable.read() takes 1 
positional argument but 2 were given`. The messages of `from_labels` did not 
count its `cls`, where PySpark's do.
   - These are now PySpark's `classmethod` and `staticmethod` objects, built 
over the native ones (`_class_member`). `read` gives the reader of the class it 
is called on, such as a subclass.
   
   **2. PrefixSpan's `clear` is `JavaParams.clear`.**
   - PrefixSpan is a `JavaParams` of PySpark of no persistence (fpm.py:317). 
Over Spark Connect, its `clear` is a `try_remote_intercept`, which takes any 
positional arguments and does nothing (wrapper.py:369).
   - The drop-in's PrefixSpan had the `clear` of PySpark's Python `Params` (of 
`persistence: python`, which is for a Pipeline or a validator). So 
`PrefixSpan().clear()` raised `missing 1 required positional argument: 
'param'`, where PySpark returns None, and `clear(param)` unset a param that 
PySpark's keeps.
   - A new `persistence: none` arm of `native_pymethods!` gives it that 
`clear`, with its own `copy`.
   
   `docs/compatibility.md` describes the class methods and static methods.
   
   ### Why are the changes needed?
   
   So that these methods have PySpark's names, signatures and errors, and 
PrefixSpan's `clear` behaves as PySpark's over Spark Connect.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, as above:
   - the class methods and static methods have PySpark's metadata and binding 
errors;
   - `PrefixSpan.clear` takes any positional arguments and does nothing.
   
   ### How was this patch tested?
   
   - **New test** in `test_ml_subclasses_offline.py`: 
`test_the_class_and_static_methods_are_pysparks_functions`. It fails on master, 
and passes here and on pyspark-client 4.3.0.
   - **Probes of both clients:** the kind, qualified name, module, docstring, 
signature and binding errors of the class members of every native class (1,647 
lines), and PrefixSpan's `clear`.
   - **Python.**
     - `test_ml_subclasses_offline.py`, `test_ml_offline.py` and 
`test_ml_api_offline.py` on pandas 2 and 3 (1266 passed each).
     - The offline suite of `coverage.yml`.
     - The related live ML files.
   - **Rust.** `cargo test -p pyspark-rs --lib`, linked as `rust.yml` links it.
   - **Lint.** `cargo fmt --all --check`, `cargo +1.100.0 clippy -p pyspark-rs 
--all-targets -- -D warnings`, ruff 0.14.0, `audit_no_stubs.sh` and 
`scripts/tests`.
   
   ### 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]

Reply via email to