dianfu commented on a change in pull request #11702: 
[FLINK-16667][python][client] Support new Python dependency configuration 
options in flink-client.
URL: https://github.com/apache/flink/pull/11702#discussion_r407982658
 
 

 ##########
 File path: 
flink-clients/src/main/java/org/apache/flink/client/cli/PythonProgramOptions.java
 ##########
 @@ -0,0 +1,140 @@
+/*
+ * 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.flink.client.cli;
+
+import org.apache.flink.client.program.PackagedProgramUtils;
+import org.apache.flink.configuration.Configuration;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.Option;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.apache.flink.client.cli.CliFrontendParser.ARGS_OPTION;
+import static org.apache.flink.client.cli.CliFrontendParser.CLASS_OPTION;
+import static org.apache.flink.client.cli.CliFrontendParser.PYARCHIVE_OPTION;
+import static org.apache.flink.client.cli.CliFrontendParser.PYEXEC_OPTION;
+import static org.apache.flink.client.cli.CliFrontendParser.PYFILES_OPTION;
+import static org.apache.flink.client.cli.CliFrontendParser.PYMODULE_OPTION;
+import static 
org.apache.flink.client.cli.CliFrontendParser.PYREQUIREMENTS_OPTION;
+import static org.apache.flink.client.cli.CliFrontendParser.PY_OPTION;
+
+/**
+ * The class for command line options that refer to a Python program or JAR 
program with Python command line options.
+ */
+public class PythonProgramOptions extends ProgramOptions {
+
+       private static final Logger LOG = 
LoggerFactory.getLogger(PythonProgramOptions.class);
+
+       private final Configuration pythonConfiguration;
+
+       PythonProgramOptions(CommandLine line) throws CliArgsException {
+               super(line);
+               try {
+                       ClassLoader classLoader;
+                       try {
+                               classLoader = new URLClassLoader(
+                                       new 
URL[]{PackagedProgramUtils.getPythonJar()},
+                                       
Thread.currentThread().getContextClassLoader());
+                       } catch (RuntimeException e) {
+                               LOG.warn(
+                                       "An attempt to load the flink-python 
jar from the \"opt\" directory failed, " +
+                                               "fall back to use the context 
class loader to reflect the flink-python class.", e);
+                               classLoader = 
Thread.currentThread().getContextClassLoader();
+                       }
+                       Class<?> utilClazz = Class.forName(
+                               
"org.apache.flink.python.util.PythonDependencyUtils",
+                               false,
+                               classLoader);
+                       Method utilMethod = utilClazz.getMethod(
 
 Review comment:
   utilMethod -> parseCommandLineMethod

----------------------------------------------------------------
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

Reply via email to