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

   ### What changes were proposed in this pull request?
   
   The native summary classes of `pyspark.ml.connect` (21 of them: the training 
and Binary summaries of the classifiers, the regression summaries and the 
clustering summaries) now have PySpark's class hierarchy, metaclass and 
constructor.
   
   - Each native training summary extends its native summary, and each Binary 
summary extends its summary (`native_summary!` of `extends $base`), and 
declares only its own members. The native subclasses add no fields, so their 
layout is their base's.
   - The public class of a native class has as bases the public classes of 
PySpark's bases of the same module (`_native_classes.publish`). So 
`BinaryLogisticRegressionTrainingSummary` is a real subclass of both 
`BinaryLogisticRegressionSummary` and `LogisticRegressionTrainingSummary`, as 
PySpark's is, where it was a virtual subclass registered by an `ABCMeta`. The 
metaclass of a public class is PySpark's (`type` for the summaries).
   - A summary constructs as PySpark's `JavaWrapper.__init__(java_obj=None)`, 
with PySpark's errors for a call that does not bind. Its members read the 
`java_obj` as PySpark's `_extract_id_methods`:
     - the id of an object of the ML cache and its methods (`"<id>.summary"`) 
of a string, over the active session;
     - `AttributeError: 'NoneType' object has no attribute 'split'` for a 
summary of no object.
   - `copy.copy` of a summary makes the copy through the class's `__new__`. 
CPython assigns no `__class__` across the native subclasses, whose deallocators 
differ.
   
   ### Why are the changes needed?
   
   So that `isinstance` and `issubclass` hold as with PySpark (through the MRO, 
not a registry), the metaclass is PySpark's, and the summary classes construct 
and fail as PySpark's do.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes, as described above.
   
   ### How was this patch tested?
   
   - New offline tests in `test_ml_subclasses_offline.py`:
     - the bases and the metaclass of every summary against PySpark's;
     - the construction and its errors.
   - A new e2e test in `test_ml_subclasses_e2e.py`: the errors of the members 
of a summary of no object, of a non-string object and of an unknown id. These 
match official PySpark 4.3.0 line for line in a probe run on both clients 
(module paths aside).
   - The CI offline list passes locally.
   
   ### 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