-
Notifications
You must be signed in to change notification settings - Fork 593
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
Propagate non-zero Picard tool exit codes. #4437
Conversation
@@ -201,6 +202,10 @@ protected final void mainEntry(final String[] args) { | |||
} | |||
handleUserException(e); | |||
System.exit(COMMANDLINE_EXCEPTION_EXIT_VALUE); | |||
} catch (PicardNonZeroExitException e) { |
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.
final
@@ -201,6 +202,10 @@ protected final void mainEntry(final String[] args) { | |||
} | |||
handleUserException(e); | |||
System.exit(COMMANDLINE_EXCEPTION_EXIT_VALUE); | |||
} catch (PicardNonZeroExitException e) { | |||
// a Picard tool returned a non-zero exit code | |||
handleResult(e.getToolReturnCode()); |
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.
Why should the result be printed on the command line?
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 did that to retain the Picard return code, which may be different than the one returned by GATK. We could make it return the actual Picard value directly, but that might be misleading since those values are not drawn from the same space as the current GATK values.
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 though that the idea was to exit with the same return code as Picard, not to print out the Picard return code and then exit with a different one. For example, for ValidateSamFile
the actual exit value has a meaning (see https://github.com/broadinstitute/picard/blob/b9b87773e9339ef6be7d61096adfc7f074b5aa74/src/main/java/picard/sam/ValidateSamFile.java#L174).
That's why I put this comment, but if that was not the idea it's fine too.
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 first order concern was to make sure that failure resulted in a non-zero return code. Otherwise, as mentioned above, the values themselves are hard not that reliable - I don't think Picard is even self-consistent, since ValidateSamFile returns 1 if there are validation warnings or if there is a command line parsing error.
35d61e2
to
90e89d9
Compare
} catch (final PicardNonZeroExitException e) { | ||
// a Picard tool returned a non-zero exit code | ||
handleResult(e.getToolReturnCode()); | ||
System.exit(ANY_OTHER_EXCEPTION_EXIT_VALUE); |
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 think it would be better to have a separate exit status code for the case where a Picard tool exits with non-0, so that clients will know to check the log to get the underlying Picard exit code.
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.
Done.
Utils.validateArg(picardToolReturnCode != 0, "Return code must be non-zero"); | ||
} | ||
|
||
public int getToolReturnCode() { return picardToolReturnCode; } |
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.
javadoc for this method
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.
Done.
final SecurityManager backup = System.getSecurityManager(); | ||
try { | ||
System.setSecurityManager(new ThrowOnExitSecurityManager()); | ||
new Main().mainEntry(new String[]{"ExtractSequences"}); |
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.
Check the return value of mainEntry()
to be sure that it's equal to the expected (non-zero) value
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.
We can't do that directly, because mainEntry never returns in this case; it exits when it detects the failure code. The custom security manager class intercepts the exit and throws the ExitNotAllowedException, which includes the code, which is asserted in the catch clause.
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.
Review complete, back to @cmnbroad, merge after addressing comments.
7f75058
to
a3497bd
Compare
Codecov Report
@@ Coverage Diff @@
## master #4437 +/- ##
===============================================
+ Coverage 79.104% 79.145% +0.041%
- Complexity 16456 16507 +51
===============================================
Files 1046 1048 +2
Lines 59165 59319 +154
Branches 9668 9697 +29
===============================================
+ Hits 46802 46948 +146
- Misses 8603 8604 +1
- Partials 3760 3767 +7
|
…en they should fail).
Fixes #4329 and #4433.