spark-test commented on code in PR #60606:
URL: https://github.com/apache/spark/pull/60606#discussion_r4608231338


##########
python/pyspark/ml/connect/AGENTS.md:
##########
@@ -0,0 +1,33 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+-->
+
+# Deprecated public APIs in `pyspark.ml.connect`
+
+The public machine learning APIs exposed by `pyspark.ml.connect` have been
+**deprecated since Spark 4.0.0**. Use the standard `pyspark.ml` APIs, which 
support
+Spark Connect.
+
+New Spark Connect clients should always exclude these deprecated public APIs 
from
+implementation and API-parity targets. Missing support for them is not a parity
+gap. Follow the standard APIs, such as
+`pyspark.ml.classification.LogisticRegression`, `pyspark.ml.Pipeline`, and
+`pyspark.ml.tuning.CrossValidator`.
+
+This directory also contains internal helpers used by standard `pyspark.ml` 
over
+Spark Connect, including [proto.py](proto.py), [serialize.py](serialize.py), 
and
+[readwrite.py](readwrite.py). These helpers remain relevant when implementing
+standard ML support in new clients.

Review Comment:
   **Non-blocking (P2):** Lines 20-21 declare every public API exposed by 
`pyspark.ml.connect` deprecated, and lines 24-26 then exclude all of them from 
implementation and parity targets. That sweeps in `functions.py`, which is 
neither deprecated nor unused:
   
   - It carries no `.. deprecated::` marker. In this package the markers appear 
only in `base.py`, `classification.py`, `evaluation.py`, `feature.py`, 
`io_utils.py`, `pipeline.py`, and `tuning.py`, the files SPARK-50828 deprecated.
   - The standard `pyspark.ml.functions.vector_to_array` and `array_to_vector`, 
documented as supporting Spark Connect since 3.5.0, call into it under 
`is_remote()` through `try_remote_functions` 
(`python/pyspark/ml/util.py:1194-1206`).
   - Its calls at `functions.py:30` and `:39` are the only place the Python 
client encodes these two functions for the server, which resolves them through 
`mllib/src/main/scala/org/apache/spark/sql/ml/InternalFunctionRegistration.scala:79`
 and `:96`.
   
   The list at lines 30-33 also leaves out `functions.py` and the 
`_extract_id_methods` helper in `util.py`, which standard ML imports to encode 
remote attribute calls such as `model.summary` (`python/pyspark/ml/util.py:98`, 
`:291`). As written, an agent scoping ML support for a new client can follow 
this file and treat missing Connect support for `vector_to_array` and 
`array_to_vector` as "not a parity gap", which is the mistake the file sets out 
to prevent.
   
   Naming the deprecated modules, rather than every public API in the package, 
puts the line where the source draws it. It also covers members of that 
framework that have no marker of their own, such as `Predictor` and 
`ParamsReadWrite.loadFromLocal`. For example:
   
   ```suggestion
   The machine learning framework in [base.py](base.py),
   [classification.py](classification.py), [evaluation.py](evaluation.py),
   [feature.py](feature.py), [io_utils.py](io_utils.py), 
[pipeline.py](pipeline.py), and
   [tuning.py](tuning.py) has been **deprecated since Spark 4.0.0**: its 
estimators,
   transformers, models, evaluators, pipelines, and tuning classes, with their 
save and
   load support. Use the standard `pyspark.ml` APIs, which support Spark 
Connect.
   
   New Spark Connect clients should always exclude these deprecated public APIs 
from
   implementation and API-parity targets. Missing support for them is not a 
parity
   gap. Follow the standard APIs, such as
   `pyspark.ml.classification.LogisticRegression`, `pyspark.ml.Pipeline`, and
   `pyspark.ml.tuning.CrossValidator`.
   
   This directory also contains code that standard `pyspark.ml` uses over Spark 
Connect:
   [proto.py](proto.py), [serialize.py](serialize.py), 
[readwrite.py](readwrite.py),
   [functions.py](functions.py), which implements the standard
   `pyspark.ml.functions.vector_to_array` and `array_to_vector` over Spark 
Connect, and
   the `_extract_id_methods` helper in [util.py](util.py), which encodes chained
   attribute access such as `model.summary` for remote calls. This code remains
   relevant when implementing standard ML support in new clients.
   ```
   
   **Verification:**
   - **Inspection:** Compare python/pyspark/ml/connect/AGENTS.md with the 
source in python/pyspark/ml/connect and python/pyspark/ml/util.py and confirm 
four things. The modules the guidance calls deprecated are exactly the seven 
whose docstrings carry `.. deprecated:: 4.0.0` (base.py, classification.py, 
evaluation.py, feature.py, io_utils.py, pipeline.py, and tuning.py), and no 
import in python/pyspark/ml/util.py names any of them. No statement puts 
functions.py, with its unmarked `vector_to_array`, `array_to_vector`, and 
`predict_batch_udf`, or the `_extract_id_methods` helper in util.py under the 
deprecation or exclusion statements. Every module that 
python/pyspark/ml/util.py imports from `pyspark.ml.connect` appears among the 
code the guidance says remains relevant, including functions.py and the 
`_extract_id_methods` helper in util.py. And every relative link in the file 
resolves to a file in python/pyspark/ml/connect.



-- 
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