tillrohrmann commented on a change in pull request #8609: 
[FLINK-12541][container][python] Add support for Python jobs in build script
URL: https://github.com/apache/flink/pull/8609#discussion_r290737434
 
 

 ##########
 File path: 
flink-container/src/main/java/org/apache/flink/container/entrypoint/ClassPathJobGraphRetriever.java
 ##########
 @@ -110,19 +117,38 @@ public JobGraph retrieveJobGraph(Configuration 
configuration) throws FlinkExcept
                }
        }
 
-       private PackagedProgram createPackagedProgram() throws FlinkException {
-               final String entryClass = getJobClassNameOrScanClassPath();
+       private PackagedProgram createPackagedProgram(final String entryClass, 
final boolean isPythonProgram) throws FlinkException {
                try {
                        final Class<?> mainClass = 
getClass().getClassLoader().loadClass(entryClass);
-                       return new PackagedProgram(mainClass, programArguments);
-               } catch (ClassNotFoundException | ProgramInvocationException e) 
{
+                       return new PackagedProgram(mainClass, 
getProgramArguments(isPythonProgram));
+               } catch (ProgramInvocationException e) {
                        throw new FlinkException("Could not load the provided 
entrypoint class.", e);
+               } catch (ClassNotFoundException e) {
+                       if (!isPythonProgram && jobPythonArtifacts != null) {
+                               return 
createPackagedProgram("org.apache.flink.python.client.PythonDriver", true);
+                       } else {
+                               throw new FlinkException("Could not load the 
provided entrypoint class.", e);
+                       }
+               }
+       }
+
+       private String[] getProgramArguments(final boolean isPythonProgram) 
throws FlinkException {
+               if (isPythonProgram) {
+                       final String[] args = new 
String[programArguments.length + 4];
+                       args[0] = "pym";
+                       args[1] = getJobEntryPointNameOrScanClassPath();
+                       args[2] = "pyfs";
+                       args[3] = jobPythonArtifacts;
+                       System.arraycopy(programArguments, 0, args, 4, 
programArguments.length);
+                       return args;
 
 Review comment:
   Why do we need to do this command line argument magic? Just because 
`PythonDriver` expects the arguments to be passed in a special order? Why not 
making the `PythonDriver` more flexible.

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