-
Notifications
You must be signed in to change notification settings - Fork 35
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
Add reset methods for each option #219
Conversation
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.
LGTM
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.
Biggest caveat from the current proposal is that the default value for every option are now defined in two separate places. If we go with this approach, I would be inclined to group the reset method with the companion setter to reduce the maintenance burden and the risks of being out-of-sync.
On the API itself, my reading of the release notes for picocli 4.6.3 is that the ability to reset all options should be built-in with the CommandLineImporter
API for certain use cases.
I assume the main driver of this API addition is to be able to reset options individually? Do you have a code snippet or a branch showing how this API is intended to be consumed downstream?
https://picocli.info/#_annotating_methods_of_a_concrete_class also suggests that the picocli-friendly way to do this is to annotate each b532b77 adds a test for resetting, which I should have done earlier. https://github.com/melissalinkert/bioformats2raw/commits/picocli-default-reset is a separate branch off that work that removes the resetters and uses the picocli-friendly |
Thanks for the extra commit for comparison. I have a slight preference for the @DavidStirling back to you, could you check whether the API changes proposed in #219 (comment) are sufficient to meet your requirements? Off-hand the only thing that seems lost from the current PR might be the ability to reset options individually to their default value. |
Resetting options individually isn't strictly critical. The one issue I have is how to access the picocli default values outside of a cli context. As it stands NGFF-Converter isn't handling The final reset method needs to live here. Currently we blow away the entire What would also be really useful is if all the setters were all capable of accepting the default value (i.e. not rejecting |
Is it a requirement to access default values separately? Or is resetting to defaults and then calling getters (which should work with either branch) sufficient?
https://github.com/melissalinkert/bioformats2raw/commits/picocli-default-reset does change all of the setters to accept the default values. That approach means that every setter gets called when the options are populated, so all setters must accept the default value by definition. In command line usage, each setter is either called with the specified command line argument, or the I don't see an obvious way to reconcile all of these points:
so we probably need to agree on which ones take priority. It sounds like https://github.com/melissalinkert/bioformats2raw/commits/picocli-default-reset is closer to ideal that what's open here, so unless any objections I'll plan to close this and open a new PR with that branch next week. |
If I can pour fuel on the fire (with the caveat that I haven't dug into |
We can probably get away without direct access, you're right there. I'd prioritise making things convenient for library usage over Picocli's expectations as Josh said. |
As discussed earlier today, closing this in favor of #226 (i.e. the branch noted above). I'm not opposed to adding a more sophisticated options API in the future, but for the moment let's focus on incremental improvement that helps our immediate needs. #226 as noted above does update the setters to accept default values (unlike what's here). |
As discussed with @DavidStirling, there wasn't a way to reset options to their default value, and some of the setters contain validation logic that prevents the default value from being accepted (e.g.
pyramidResolutions
).This PR adds a
reset
method corresponding to theget
andset
method for each option.resetOptions()
calls each individual option's resetter for convenience. Open to other thoughts on how to implement this, what's in 5a99e2b was just the most straightforward change.Once we're happy with changes here, raw2ometiff will need the same treatment. This may end up being what drives the 0.8.0 release.