-
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
[CLI] Shorthand notation to instantiate callbacks [3/3] #8815
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## master #8815 +/- ##
========================================
- Coverage 93% 43% -49%
========================================
Files 175 175
Lines 14402 14543 +141
========================================
- Hits 13342 6319 -7023
- Misses 1060 8224 +7164 |
tchaton
commented
Aug 9, 2021
carmocca
reviewed
Aug 10, 2021
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.
Can you add to the post the following?:
- Motivation
- What's new
- What was changed
carmocca
reviewed
Aug 10, 2021
for more information, see https://pre-commit.ci
User can registered their own callbacks. Somehow it doesn't work within the tests. from unittest import mock
from pytorch_lightning import Callback
from pytorch_lightning.utilities.cli import CALLBACK_REGISTRIES, LightningCLI
from tests.helpers import BoringModel
class CustomCallback(Callback):
pass
CALLBACK_REGISTRIES(cls=CustomCallback, override=True)
with mock.patch("sys.argv", ["any.py", "--trainer.callbacks=[{'class_path': test.CustomCallback}]"]):
cli = LightningCLI(BoringModel, trainer_defaults=dict(fast_dev_run=True), run=False)
callbacks = [c for c in cli.trainer.callbacks if isinstance(c, CustomCallback)]
assert len(callbacks) == 1 |
tchaton
requested review from
awaelchli,
Borda,
edenlightning and
justusschock
as code owners
August 10, 2021 14:50
12 tasks
carmocca
changed the base branch from
master
to
feat/cli-shorthand-optimizers
September 16, 2021 17:24
carmocca
changed the title
[feat] LightningCLI simplification through registries
[CLI] Shorthand notation to instantiate callbacks [3/3]
Sep 16, 2021
carmocca
added
callback
argparse (removed)
Related to argument parsing (argparse, Hydra, ...)
and removed
has conflicts
labels
Sep 16, 2021
carmocca
approved these changes
Sep 16, 2021
for more information, see https://pre-commit.ci
SeanNaren
pushed a commit
that referenced
this pull request
Sep 22, 2021
Co-authored-by: Carlos Mocholi <carlossmocholi@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
argparse (removed)
Related to argument parsing (argparse, Hydra, ...)
callback
feature
Is an improvement or enhancement
ready
PRs ready to be merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Part of #7250
Implements the feature request in jsonargparse: omni-us/jsonargparse#85
co-author: @carmocca
Does your PR introduce any breaking changes? If yes, please list them.
None
Before submitting
PR review