Skip to content

Improve error message when LightningCLI(run=False) but user passes a stage as argument #18203

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

Open
awaelchli opened this issue Jul 31, 2023 · 1 comment
Labels
3rd party Related to a 3rd-party feature Is an improvement or enhancement lightningcli pl.cli.LightningCLI

Comments

@awaelchli
Copy link
Contributor

awaelchli commented Jul 31, 2023

Description & Motivation

This is a proposal to adjust the current error message

 error: Unrecognized arguments: fit

to something more meaningful when run=False and passing a stage is not needed. Below is a minimal example that demonstrates this:

from lightning.pytorch import LightningModule
from lightning.pytorch.cli import LightningCLI


class BoringModel(LightningModule):
    pass


def main():
    cli = LightningCLI(BoringModel, run=False)
    cli.trainer.fit(cli.model)


if __name__ == "__main__":
    main()

Run it like so:

python bug_report/bug_report_model.py fit

Error:

...
bug_report_model.py: error: Unrecognized arguments: fit

Pitch

Adjust the error for this case to a message like this, pointing out that run=False was configured.

Error: You passed 'fit' as stage but the LightningCLI is configured with run=False. Selecting a stage in this case is not supported.

Alternatives

Keep as is

Additional context

Raised by a question of a user in slack channel

cc @Borda @carmocca @mauvilsa

@awaelchli awaelchli added feature Is an improvement or enhancement needs triage Waiting to be triaged by maintainers lightningcli pl.cli.LightningCLI and removed needs triage Waiting to be triaged by maintainers labels Jul 31, 2023
@mauvilsa
Copy link
Contributor

This might be a possibility omni-us/jsonargparse#335 (comment)

@awaelchli awaelchli added the 3rd party Related to a 3rd-party label Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party Related to a 3rd-party feature Is an improvement or enhancement lightningcli pl.cli.LightningCLI
Projects
None yet
Development

No branches or pull requests

2 participants