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


##########
mllib/src/main/scala/org/apache/spark/ml/clustering/GaussianMixture.scala:
##########
@@ -477,7 +482,9 @@ class GaussianMixture @Since("2.0.0") (
      .setName("training instances")
 
     val handlePersistence = dataset.storageLevel == StorageLevel.NONE
-    if (handlePersistence) { instances.persist(StorageLevel.MEMORY_AND_DISK) }
+    if (handlePersistence) {
+      instances.persist(StorageLevel.fromString($(intermediateStorageLevel)))

Review Comment:
   **Nit (P3):** This line is the PR's only change to how `fit` handles the 
training data, but no committed test observes it. The new assertions in 
`GaussianMixtureSuite` and `test_gaussian_mixture` read the param back through 
getters, setters and save/load, and `testEstimatorAndModelReadWrite` compares 
only param values and model data, neither of which depends on the storage 
level. Judging by what the tests assert, reverting this line to 
`instances.persist(StorageLevel.MEMORY_AND_DISK)` would leave every test green. 
A later refactor that drops the param would then ship unnoticed, and users who 
set `DISK_ONLY` to keep training data out of executor memory would silently get 
`MEMORY_AND_DISK`.
   
   The PR description mentions a local listener check that saw `DISK_ONLY` on 
the training-instances RDD; committing it as a test in `GaussianMixtureSuite` 
would close the gap. The ALSSuite test "default and non-default storage params 
set correct RDD StorageLevels" shows the pattern: a `SparkListener` that reads 
each completed stage's `rddInfos`; here it would match the `training instances` 
RDD by name. Every GaussianMixture fit in the suite names its RDD that way, and 
the listener bus also delivers events that are still queued when a listener is 
attached, so drain the bus before attaching each fit's listener to keep events 
from earlier fits out of it.
   
   **Verification:**
   - **Behavior:** Fitting GaussianMixture on an uncached input persists the 
RDD named 'training instances' at MEMORY_AND_DISK when intermediateStorageLevel 
is left at its default, and at the chosen level when it is set to a non-default 
value such as DISK_ONLY. The test reads that level from the stage events of 
that fit alone, collected once the listener bus has drained, and fails if the 
RDD was never observed.
   - **Regression:** The non-default case fails when fit ignores the param and 
persists the training instances at MEMORY_AND_DISK, as the base branch does.



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