-
Notifications
You must be signed in to change notification settings - Fork 28.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-24319][SPARK SUBMIT] Fix spark-submit execution where no main class is required. #21450
Conversation
…class is required.
test this please |
Test build #91262 has finished for PR 21450 at commit
|
cc @vanzin |
Test build #91267 has finished for PR 21450 at commit
|
This doesn't seem to be addressing the issue reported in the bug. The exact same error happens with your patch:
|
Updated the description to reflect the no arg case as well. |
Test build #91299 has finished for PR 21450 at commit
|
@@ -229,7 +238,7 @@ | |||
args.add(join(",", pyFiles)); | |||
} | |||
|
|||
if (isExample) { | |||
if (isExample && requiresMainClass) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In what situation will requiresAppResource
be different from requiresMainClass
at this point?
It seems to me they're basically the same. The only point in your code where they differ is in the no-arg constructor, which is not used by the run-example
script.
Seems to me like you could rename the existing variable to isSpecialCommand
or something and use it instead for both cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally I was hesitating to merge them and loose the 2 different meaning but it's better. Added a small comment.
private void testCLIOpts(String opt) throws Exception { | ||
List<String> helpArgs = Arrays.asList(opt, "driver-20160531171222-0000"); | ||
private void testCLIOpts(String appResource, String opt, List<String> params) throws Exception { | ||
List<String> helpArgs = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're changing this, probably better to rename the variable since these are not help arguments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed.
@@ -190,6 +194,23 @@ public void testSparkRShell() throws Exception { | |||
env.get("SPARKR_SUBMIT_ARGS")); | |||
} | |||
|
|||
@Test | |||
public void testExamplesRunnerNoArg() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When no args are given this is what I get as the output:
$ bin/run-example
Error: Must specify a primary resource (JAR or Python or R file)
Run with --help for usage help or --verbose for debug output
It doesn't really make sense asking for a primary resource when running an example, how about just printing usage? This is what spark-submit does with no args
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, the output should make sense also.
When the launcher library detects an invalid command it should be running spark-submit --usage-error
, which should print usage with the overridden description from the run-example
script. That's done in Main.java
when it catches an IllegalArgumentException
.
Seems that's not exactly what's happening here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it prints out the usage.
Test build #91390 has finished for PR 21450 at commit
|
This is still missing something.
|
ok to test |
Test build #91598 has finished for PR 21450 at commit
|
Test build #91698 has finished for PR 21450 at commit
|
The issue seems unrelated.
Trying to rebase the changes to the latest master. |
Test build #91700 has finished for PR 21450 at commit
|
OptionParser parser = new OptionParser(true); | ||
parser.parse(submitArgs); | ||
this.requiresAppResource = parser.requiresAppResource; | ||
if (!submitArgs.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you need this check? parser.isSpecialCommand
is initialized to false
, so seems like it's already handled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed as it leads to the same result.
* Prepare spark commands with the appropriate command builder. | ||
* If printLaunchCommand is set then the commands will be printed to the stderr. | ||
*/ | ||
private static List<String> buildCommand(AbstractCommandBuilder builder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the Spark style for multi-line parameter lists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Just for the sake of my understanding what does many
mean in the following? All?
For Java code, Apache Spark follows Oracle’s Java code conventions. Many Scala guidelines below also apply to Java.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read that as "unless it cannot apply to Java at all, follow the Scala style".
|
||
@Test | ||
public void testExamplesRunnerWithMasterNoMainClass() throws Exception { | ||
testExamplesRunnerWithMasterNoMainClassEx.expect(IllegalArgumentException.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a slight preference for a try...catch
in this case, which would also be less code, but either is fine. But I'd pick a shorter and more generic name for the rule (since it could be reused in other tests if needed later).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed.
Test build #91763 has finished for PR 21450 at commit
|
* If printLaunchCommand is set then the commands will be printed to the stderr. | ||
*/ | ||
private static List<String> buildCommand( | ||
AbstractCommandBuilder builder, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The style is to double indent parameter lists... when in doubt, look at the rest of the code, not the style guide.
Test build #91853 has finished for PR 21450 at commit
|
Looks good. "run-example --kill blah" is kinda weird, but not worth it to handle that case. Merging to master. |
What changes were proposed in this pull request?
With PR 20925 now it's not possible to execute the following commands:
In this PR the execution will be allowed for the mentioned commands.
How was this patch tested?
Existing unit tests extended + additional written.