WeichenXu123 commented on code in PR #40607:
URL: https://github.com/apache/spark/pull/40607#discussion_r1153066202


##########
python/pyspark/ml/torch/distributor.py:
##########
@@ -581,11 +593,11 @@ def _run_distributed_training(
             f"Started distributed training with {self.num_processes} executor 
proceses"
         )
         try:
+            assert self.spark is not None
             result = (
-                self.sc.parallelize(range(self.num_tasks), self.num_tasks)
-                .barrier()
-                .mapPartitions(spark_task_function)
-                .collect()[0]
+                self.spark.range(start=0, end=self.num_tasks, step=1, 
numPartitions=self.num_tasks)
+                .mapInPandas(func=spark_task_function, schema="output binary", 
barrier=True)
+                .first()["output"]

Review Comment:
   I think barrier mode mapping result dataframe does not support `.first()` 
operation if I remember it correctly



-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to