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
WandBLogger: Can't set log_model from LightningCLI due to problem in type hint #18370
Comments
@SebastianGer Thanks for reporting. Does the problem still persist when upgrading jsonargparse to the latest? |
Yes. After upgrading to The same thing happens when I exchange bool for float. I find it difficult to find the responsible spot in the jsonargparse code, but I assume they just iterate through possible types and pick the first one that fits, to resolve the type ambiguity. Seems like a reasonable design decision, just one that is easy to overlook. |
@mauvilsa Do you agree with the proposal from @SebastianGer? Switching the order or using Literal? |
Correct.
If only |
@SebastianGer are you interested in sending a PR with the change? |
@awaelchli Sure. Will take a few days, but I'll try. |
Bug description
The WandB logger has an init argument
log_model
of typeUnion[str, bool]
(see the class definition).I can set this value to
True
orFalse
as part of a config file that I pass to the LightningCLI. However, this does not work via the command line. Setting--trainer.logger.init_args.log_model=True
results in the value being represented internally as'True'
, of type String.From what I can tell, this can be fixed by switching the order of types in the Union type hint, to prefer the boolean interpretation, if both are possible. Even better would be to use the
Literal
type, since only one String value should actually be accepted, according to the docs:Union[Literal["all"],bool]
. Both work, according to my testing.What version are you seeing the problem on?
v2.0
How to reproduce the bug
Error messages and logs
No response
Environment
Current environment
More info
No response
cc @Borda @carmocca @mauvilsa
The text was updated successfully, but these errors were encountered: