-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
Question about parse a list of dict #421
Comments
This is because your shell is modifying the values before they get to the python code. You need to quote them to prevent this.
|
Thank you. The second one works. But the first one did not work. --model.augmentations+='{"c":"random_mosaic"}' --model.augmentations+='{"d":"random_perspective"}'
#Error message
error: 'Configuration check failed :: No action for destination key "augmentations+.c" to check its value.'
|
I can look into what happened with the first one. But you need to provide the exact type hint of |
The type hint: def __init__(
self,
augmentations: list[dict[str,str]] = [{"a":"random_crop"},{"b":"random_blur"}],
) -> None: The shell I am using is |
Why do you use an old version of jsonargparse? Not sure if something related to this has been fixed since 4.21, but better if you install the latest version. I haven't had time to look in more detail. But |
Hi, @mauvilsa The LightningCLI And I upgraded error: Validation failed: No action for key "augmentations+.c" to check its value. |
With from lightning.pytorch.demos.boring_classes import BoringModel
from lightning.pytorch.cli import LightningCLI
class MyModel(BoringModel):
def __init__(
self,
augmentations: list[dict[str,str]] = [{"a":"random_crop"},{"b":"random_blur"}],
) -> None:
pass
if __name__ == '__main__':
cli = LightningCLI(MyModel, subclass_mode_model=False) In ubuntu 22.04 and python 3.10 I get the following: $ ./issue_421.py fit --model.augmentations+='{"c":"random_mosaic"}' --model.augmentations+='{"d":"random_perspective"}' --print_config
...
model:
augmentations:
- a: random_crop
- b: random_blur
- c: random_mosaic
- d: random_perspective
... However, if $ ./issue_421.py fit --model=MyModel --model.init_args.augmentations+='{"c":"random_mosaic"}' --model.init_args.augmentations+='{"d":"random_perspective"}' --print_config
usage: issue_421.py [-h] [-c CONFIG] [--print_config[=flags]] {fit,validate,test,predict} ...
error: Validation failed: No action for key "augmentations+.c" to check its value. Did you mean to say that |
Hi, @mauvilsa Appears the self.subclass_mode_model = (model_class is None) or subclass_mode_model |
I'm trying to parse a arg that is a list of dict use the comand line tool:
The yaml:
Expected result:
The command line arg I try:
1.
How to properly parse a list of dict use cli?
The text was updated successfully, but these errors were encountered: