-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Support CLI shorthand natively #12614
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.
Until _convert_argv_issue_85 is removed, still there is a need to register the callbacks. But assuming that this is done, there is a general question. Should the registries be deprecated?
If we have no use for them, yes.
- Only accept ReduceLROnPlateau defined in cli module.
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.
This is great!
Follow-ups would be:
- Deprecate registries
- Deprecate
LightningCLI(auto_registry=...)
- Rewrite docs
This is missing the milestone. I guess it would be 1.7, right? |
hey @mauvilsa! |
This is why I implemented |
What does this PR do?
Uses a new version of jsonargparse which implements for subclasses the support for short command line arguments and specifying only the class name instead of the full class path. This allows to remove the placeholder
LightningArgumentParser._convert_argv_issue_84
.The idea with the 4.6.0 version of jsonargparse is that all subclasses for the given base classes can be specified by name. No need to explicitly register them. The only requirement is that the module where the subclass is defined, is imported prior to parsing. For example in the case of
--lr_scheduler
two base classes are giventorch.optim.lr_scheduler.{_LRScheduler,ReduceLROnPlateau}
. All subclasses in the same module are already known by the parser, so for instance--lr_scheduler ExponentialLR
would already work. One nice benefit of this is that many other parameters get the same support without needing to implement a register for it, e.g.--trainer.accelerator
. And also works for user defined parameters, e.g. a module with signaturedef __init__(self, encoder: EncoderBase, decoder: DecoderBase):
.This does not introduce any breaking change, though it does make the registries a bit misleading. The CLIs might support more classes than what the registry has. Also using a decorator, e.g.
@MODEL_REGISTRY
, makes no difference. The module where a class is defined has to be imported for the decorator to register it. But since it is imported, the parser already knows about this class and supports it without having to register it.Until
_convert_argv_issue_85
is removed, still there is a need to register the callbacks. But assuming that this is done, there is a general question. Should the registries be deprecated?Fixes #12464
Does your PR introduce any breaking changes? If yes, please list them.
None
Before submitting
PR review
Anyone in the community is welcome to review the PR.
Before you start reviewing make sure you have read Review guidelines. In short, see the following bullet-list:
Did you have fun?
Make sure you had fun coding 🙃