dianfu commented on a change in pull request #10430: [FLINK-14019][python][cli]
Add command-line options for managing Python UDF environment and dependencies.
URL: https://github.com/apache/flink/pull/10430#discussion_r354674349
##########
File path:
flink-clients/src/main/java/org/apache/flink/client/cli/ProgramOptions.java
##########
@@ -80,51 +86,24 @@ public ProgramOptions(CommandLine line) throws
CliArgsException {
isPython = line.hasOption(PY_OPTION.getOpt()) |
line.hasOption(PYMODULE_OPTION.getOpt())
|
"org.apache.flink.client.python.PythonGatewayServer".equals(entryPointClass);
// If specified the option -py(--python)
- if (line.hasOption(PY_OPTION.getOpt())) {
- // Cannot use option -py and -pym simultaneously.
- if (line.hasOption(PYMODULE_OPTION.getOpt())) {
- throw new CliArgsException("Cannot use option
-py and -pym simultaneously.");
- }
- // The cli cmd args which will be transferred to
PythonDriver will be transformed as follows:
- // CLI cmd : -py ${python.py} pyfs [optional]
${py-files} [optional] ${other args}.
- // PythonDriver args: py ${python.py} [optional] pyfs
[optional] ${py-files} [optional] ${other args}.
- //
-------------------------------transformed-------------------------------------------------------
- // e.g. -py wordcount.py(CLI cmd) -----------> py
wordcount.py(PythonDriver args)
- // e.g. -py wordcount.py -pyfs
file:///AAA.py,hdfs:///BBB.py --input in.txt --output out.txt(CLI cmd)
- // -----> -py wordcount.py -pyfs
file:///AAA.py,hdfs:///BBB.py --input in.txt --output out.txt(PythonDriver args)
- String[] newArgs;
- int argIndex;
- if (line.hasOption(PYFILES_OPTION.getOpt())) {
- newArgs = new String[args.length + 4];
- newArgs[2] = "-" + PYFILES_OPTION.getOpt();
- newArgs[3] =
line.getOptionValue(PYFILES_OPTION.getOpt());
- argIndex = 4;
- } else {
- newArgs = new String[args.length + 2];
- argIndex = 2;
- }
- newArgs[0] = "-" + PY_OPTION.getOpt();
- newArgs[1] = line.getOptionValue(PY_OPTION.getOpt());
- System.arraycopy(args, 0, newArgs, argIndex,
args.length);
- args = newArgs;
- }
-
- // If specified the option -pym(--pyModule)
- if (line.hasOption(PYMODULE_OPTION.getOpt())) {
- // If you specify the option -pym, you should specify
the option --pyFiles simultaneously.
- if (!line.hasOption(PYFILES_OPTION.getOpt())) {
- throw new CliArgsException("-pym must be used
in conjunction with `--pyFiles`");
+ if (isPython) {
Review comment:
Nice change!
----------------------------------------------------------------
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