Skip to content

[SPARK-51880][FOLLOW-UP] Fix LDAModel.toLocal #50788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions python/pyspark/ml/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from pyspark.ml.wrapper import JavaEstimator, JavaModel, JavaParams, JavaWrapper
from pyspark.ml.common import inherit_doc
from pyspark.ml.stat import MultivariateGaussian
from pyspark.ml.util import RemoteModelRef
from pyspark.sql import DataFrame
from pyspark.ml.linalg import Vector, Matrix
from pyspark.sql.utils import is_remote
Expand Down Expand Up @@ -1581,10 +1582,9 @@ def toLocal(self) -> "LocalLDAModel":

.. warning:: This involves collecting a large :py:func:`topicsMatrix` to the driver.
"""
model = LocalLDAModel(self._call_java("toLocal"))
if is_remote():
return model

return LocalLDAModel(RemoteModelRef(self._call_java("toLocal")))
model = LocalLDAModel(self._call_java("toLocal"))
# SPARK-10931: Temporary fix to be removed once LDAModel defines Params
model._create_params_from_java()
model._transfer_params_from_java()
Expand Down
2 changes: 0 additions & 2 deletions python/pyspark/ml/tests/test_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,6 @@ def test_local_lda(self):
self.assertEqual(str(model), str(model2))

def test_distributed_lda(self):
if is_remote():
self.skipTest("Do not support Spark Connect.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems this test is still not compatible with connect

spark = self.spark
df = (
spark.createDataFrame(
Expand Down