Skip to content
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 custom key registration does not work #12791

Closed
carmocca opened this issue Apr 18, 2022 · 1 comment
Closed

CLI custom key registration does not work #12791

carmocca opened this issue Apr 18, 2022 · 1 comment
Assignees
Labels
bug Something isn't working lightningcli pl.cli.LightningCLI
Milestone

Comments

@carmocca
Copy link
Contributor

carmocca commented Apr 18, 2022

🐛 Bug

To Reproduce

from pytorch_lightning import LightningModule
from pytorch_lightning.utilities.cli import LightningCLI, MODEL_REGISTRY


class DemoModel(LightningModule):
    ...


MODEL_REGISTRY(DemoModel, key="test")

cli = LightningCLI()
$ python kk.py fit --model=test
Traceback (most recent call last):
  File "/home/carmocca/git/pytorch-lightning/kk.py", line 11, in <module>
    cli = LightningCLI()
  File "/home/carmocca/git/pytorch-lightning/pytorch_lightning/utilities/cli.py", line 553, in __init__
    self.parse_arguments(self.parser)
  File "/home/carmocca/git/pytorch-lightning/pytorch_lightning/utilities/cli.py", line 694, in parse_arguments
    self.config = parser.parse_args()
  File "/home/carmocca/git/pytorch-lightning/pytorch_lightning/utilities/cli.py", line 265, in parse_args
    argv = self._convert_argv_issue_84(classes, k, argv)
  File "/home/carmocca/git/pytorch-lightning/pytorch_lightning/utilities/cli.py", line 341, in _convert_argv_issue_84
    raise ValueError(f"Could not generate a config for {repr(argv_class)}")
ValueError: Could not generate a config for 'test'

This happens because this line should be checking with the registered key, not the class name: https://github.com/PyTorchLightning/pytorch-lightning/blob/ae3226ced96e2bc7e62f298d532aaf2290e6ef34/pytorch_lightning/utilities/cli.py#L314

Expected behavior

Works and instantiates the DemoModel

cc @carmocca @mauvilsa

@carmocca carmocca added bug Something isn't working lightningcli pl.cli.LightningCLI labels Apr 18, 2022
@carmocca carmocca added this to the 1.6.x milestone Apr 18, 2022
@carmocca carmocca self-assigned this Apr 18, 2022
@carmocca
Copy link
Contributor Author

carmocca commented May 3, 2022

Since the registries are going to be deprecated (#12961), this can be closed

@carmocca carmocca closed this as completed May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lightningcli pl.cli.LightningCLI
Projects
None yet
Development

No branches or pull requests

1 participant