harupy commented on code in PR #39188: URL: https://github.com/apache/spark/pull/39188#discussion_r1068923718
########## python/pyspark/ml/torch/distributor.py: ########## @@ -261,6 +312,130 @@ def __init__( super().__init__(num_processes, local_mode, use_gpu) self.ssl_conf = "pytorch.spark.distributor.ignoreSsl" # type: ignore self._validate_input_params() + self.input_params = self._create_input_params() + + @staticmethod + def _create_torchrun_command( + input_params: dict[str, Any], path_to_train_file: str, *args: Any + ) -> list[str]: + local_mode = input_params["local_mode"] + num_processes = input_params["num_processes"] + + if local_mode: + torchrun_args = ["--standalone", "--nnodes=1"] + processes_per_node = num_processes + else: + pass + # TODO(SPARK-41592): Handle distributed training Review Comment: Not an issue if `local_mode` is always True, but code like below leaves `x` undefined when `condition` is False and causes an error. ``` if condition: x = else: ... # Do something with x print(x) ``` ########## python/pyspark/ml/torch/distributor.py: ########## @@ -261,6 +312,130 @@ def __init__( super().__init__(num_processes, local_mode, use_gpu) self.ssl_conf = "pytorch.spark.distributor.ignoreSsl" # type: ignore self._validate_input_params() + self.input_params = self._create_input_params() + + @staticmethod + def _create_torchrun_command( + input_params: dict[str, Any], path_to_train_file: str, *args: Any + ) -> list[str]: + local_mode = input_params["local_mode"] + num_processes = input_params["num_processes"] + + if local_mode: + torchrun_args = ["--standalone", "--nnodes=1"] + processes_per_node = num_processes + else: + pass + # TODO(SPARK-41592): Handle distributed training Review Comment: Not an issue if `local_mode` is always True, but code like below leaves `x` undefined when `condition` is False and causes an error. ```python if condition: x = else: ... # Do something with x print(x) ``` -- 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