hequn8128 commented on a change in pull request #10061: [FLINK-14581][python]
Let python UDF execution no longer rely on the flink directory structure to
support running python UDFs on yarn.
URL: https://github.com/apache/flink/pull/10061#discussion_r342483072
##########
File path:
flink-python/src/main/java/org/apache/flink/python/AbstractPythonFunctionRunner.java
##########
@@ -293,15 +311,31 @@ private static String randomString(Random random) {
*/
protected RunnerApi.Environment createPythonExecutionEnvironment() {
if (pythonEnv.getExecType() == PythonEnv.ExecType.PROCESS) {
- String flinkHomePath =
System.getenv(ConfigConstants.ENV_FLINK_HOME_DIR);
- String pythonWorkerCommand =
- flinkHomePath + File.separator + "bin" +
File.separator + "pyflink-udf-runner.sh";
-
+ Random rnd = new Random();
+ String tmpdir = tempDirs[rnd.nextInt(tempDirs.length)];
+ String prefix = UUID.randomUUID().toString() + "_";
+ try {
+ pythonFiles =
RunnerEnvUtil.extractBasicDependenciesFromResource(
+ tmpdir,
this.getClass().getClassLoader(), prefix);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ String pythonWorkerCommand = null;
+ for (File file: pythonFiles) {
+ file.deleteOnExit();
+ if
(file.getName().endsWith("pyflink-udf-runner.sh")) {
+ pythonWorkerCommand =
file.getAbsolutePath();
+ pythonFiles.remove(file);
+ break;
+ }
+ }
+ Map<String, String> env =
RunnerEnvUtil.appendEnvironmentVariable(System.getenv(),
Review comment:
Put `System.getenv(),` to a new line.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services