haiyangsun-db commented on code in PR #55611: URL: https://github.com/apache/spark/pull/55611#discussion_r3192230106
########## sql/core/src/main/scala/org/apache/spark/sql/execution/externalUDF/PythonUDFWorkerSpecification.scala: ########## @@ -0,0 +1,114 @@ +/* + * 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. + */ +package org.apache.spark.sql.execution.externalUDF + +import scala.jdk.CollectionConverters._ + +import org.apache.spark.SparkConf +import org.apache.spark.annotation.Experimental +import org.apache.spark.api.python.{PythonFunction, PythonUtils} +import org.apache.spark.internal.config.Python.PYTHON_WORKER_MODULE +import org.apache.spark.udf.worker._ + +/** + * :: Experimental :: + * Builds a [[UDFWorkerSpecification]] for Python UDFs from a + * [[PythonFunction]] and [[SparkConf]]. + * + * Reuses the same information the existing + * [[org.apache.spark.api.python.PythonWorkerFactory]] uses: + * - `pythonExec` from the function + * - Environment variables from the function (which already + * contain the caller-assembled `PYTHONPATH`), merged with + * Spark's built-in Python path and the system `PYTHONPATH` + * - Worker module from `spark.python.worker.module` + * + * Note: `pythonIncludes` are not added to the process + * environment. They are sent over the data channel to the + * already-running worker by the runner (see + * [[org.apache.spark.api.python.PythonRunner]]). + */ +@Experimental +object PythonUDFWorkerSpecification { Review Comment: this piece feel like testable - ensure that the direct worker dispatcher can use this spec to launch a functioning pyspark worker. -- 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]
