-
Notifications
You must be signed in to change notification settings - Fork 591
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
Major changes to the command line parsing system #135
Conversation
jopt-simple docs are here http://pholser.github.io/jopt-simple/ |
Coverage decreased (-0.29%) to 63.41% when pulling eb1a39e3e6e5454f59be1d76e8ae9c9ab8dcbbba on lb_unix_style_options into 93aad64 on master. |
try { | ||
createOptionDefinitions(field.get(callerOptions)); | ||
} catch (final IllegalAccessException e) { | ||
throw new GATKException.CommandLineParserInternalException("BUG: NestedArguments must be public must be public.", 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.
Minor typo 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.
Ooh, thanks.
I believe |
It seemed like it was for child parsers to be able to override the master |
ArgumentsBuilder args = new ArgumentsBuilder(new Object[]{"Option=" + new File("/path/to"), "OtherOption=" + -1}); | ||
Assert.assertEquals(args.getArgsArray(), new String[]{"--Option","/path/to", "--OtherOption", "-1"}); | ||
} | ||
|
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'd say either create a separate class with the actual @Test
s, or move this whole class to src/test
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.
oops, i had meant to do that
On Wed, Jan 21, 2015 at 6:18 PM, Matt Sooknah [email protected]
wrote:
In
src/main/java/org/broadinstitute/hellbender/utils/test/ArgumentsBuilder.java
#135 (comment)
:
- }
- @test
- public void testOneBigString(){
ArgumentsBuilder args = new ArgumentsBuilder();
args.add(" Value=1 Value=2 Value=3 Value= 4 ");
Assert.assertEquals(args.getArgsList().toArray(), new String[]{"--Value", "1", "--Value", "2",
"--Value", "3","--Value", "4"});
- }
- @test
- public void testFromArray(){
ArgumentsBuilder args = new ArgumentsBuilder(new Object[]{"Option=" + new File("/path/to"), "OtherOption=" + -1});
Assert.assertEquals(args.getArgsArray(), new String[]{"--Option","/path/to", "--OtherOption", "-1"});
- }
I'd say either create a separate class with the actual @tests, or move
this whole class to src/test—
Reply to this email directly or view it on GitHub
https://github.com/broadinstitute/hellbender/pull/135/files#r23343682.
2f67422
to
2b3620e
Compare
Coverage decreased (-0.2%) to 63.5% when pulling 2b3620e42107d0090f3fc270fdfca14ec7d682c7 on lb_unix_style_options into 93aad64 on master. |
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import java.lang.annotation.*; |
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 should standardize on the style of imports or we'll have those edits all the time. Issue #138
looks good, small comments. CommandlineLineParser is a pretty complex beast and I've not reviewed it fully but it's fine for now from me. @droazen should weigh in on this pull req too before you merge. |
Coverage decreased (-0.21%) to 63.5% when pulling e48a1360708acbb82b1179a5897c4039b5f067f6 on lb_unix_style_options into 93aad64 on master. |
} | ||
|
||
// This is the object that the caller has provided that contains annotations, | ||
// and into which the values will be assigned. | ||
private final Object callerOptions; | ||
|
||
// For child CommandLineParser, this contains the prefix for the option names, which is needed for generating | ||
// the command line. For non-nested, this is the empty string. | ||
private final String prefix; |
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.
good riddance to this garbage :)
Not sure if this is the right place for me to jump in (so redirect me if not), but question: is there any plan to make it possible to define min/max values for numeric argument values? This is something we got to only in a very basic way in GATK but would be useful to enable in order to save users from themselves. This would involve two levels:
|
for (String stringValue: values) { | ||
final Object value; | ||
try { | ||
if (stringValue.equals("null")) { |
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.
Should be a named constant rather than hardcoded literal.
Review complete. Looks great, just a few relatively minor comments. |
@vdauwera General arg checking can be done in But it might be nice to have a more specific process for checking values of numeric args. |
@vdauwera If you want this (or any other) feature from the old GATK to make it into hellbender, feel free to create a ticket in our github issue tracker -- we can always close as WONTFIX if we deem it impractical or incompatible with the new codebase. I don't think adding minValue/maxValue attributes to @option would be a problem, though. |
Thanks guys -- will create tickets from now on. |
e48a136
to
eb6062f
Compare
Coverage decreased (-0.21%) to 63.5% when pulling eb6062f11e8c37cf1ab512913dfac04e573bd38b on lb_unix_style_options into 9195042 on master. |
eb6062f
to
8a93d43
Compare
-using jopt-simple to do the actual parsing -supports short (-h) and long (--help) styles -supports boolean flags with or without an argument -options are now case sensitive -argument collections can be specified with @ArgumentCollection -Option(fullname) is now respected if specified, if it isn't it defaults to use the field name -several Option values are no longer used, overrideable -NestedOptions removed -> replaced by ArgumentCollection -Arguments must now be uniquely specified (no arguments targetting multiple fields any more) -Collection defaults are now replaced rather than appended too -opportunistically fixed a broken test in CreateSequenceDictionaryTest
I think I've addressed all the comments. Going to merge on travis success. |
* revises explore to work with Interpretation * deletes lingering pdb.set_trace() * Interpretation enums * Interpretation for string and continuous * Tested continuous * Nitpicks * adds parenthesis * Nate's requested changes plus others: 1. If tensor is scaler (`if tm.shape[0] == 1`), isolates the value inside the numpy array via `tensor = tensor.item`. If not, retain the value as an array (e.g. categorical labels). 2. In the DataFrame, casts the `fpath`, `generator`, and any tm with that has `Interpretation.Language` into "string" dtypes (see https://pandas.pydata.org/pandas-docs/stable/user_guide/text.html). This may confer some speed benefit in the future compared to the default `object` dtype. 3. If dropping NaN rows from dataframe (how we obtain intersect of tensor maps) results in an empty dataframe, skips calculating summary statistics. Previous attempts to do that threw errors. * removes import pdb Co-authored-by: paolodi <[email protected]>
using jopt-simple to do the actual parsing. Right now it's just been dropped in to handle decomposing the arguments into key->value pairs.
supports short (-h) and long (--help) styles
supports boolean flags with or without an argument
options are now case sensitive
argument collections can be specified with
@ArgumentCollection
NestedOptions
removed -> replaced byArgumentCollection
Option.fullName()
is now respected if specified, if it isn't it defaults to use the field nameOverrideable
has been removed fromOption
Arguments must now be uniquely specified (no arguments targeting multiple fields any more) and no redefining existing ones.
The ability to override a specified option is a useful one, so it might need to be reimplemented at some point.
Collection defaults are now replaced rather than appended too
also opportunistically fixed a broken test in
CreateSequenceDictionaryTest
using jopt-simple to do the actual parsing. Right now it's just been dropped in to handle decomposing the arguments into key->value pairs. In future it could also handle more of the argument checking and help formatting.supports short (-h) and long (--help) styles
supports boolean flags with or without an argument
options are now case sensitive
argument collections can be specified with
@ArgumentCollection
NestedOptions
removed -> replaced byArgumentCollection
Option.fullName()
is now respected if specified, if it isn't it defaults to use the field nameOverrideable
has been removed fromOption
Arguments must now be uniquely specified (no arguments targeting multiple fields any more) and no redefining existing ones.
The ability to override a specified option is a useful one, so it might need to be reimplemented at some point.
Collection defaults are now replaced rather than appended too
also opportunistically fixed a broken test in
CreateSequenceDictionaryTest