-
-
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
Support passing lists of class_path items via command line #85
Comments
Looks reasonable. |
I have been thinking about this a bit to have a clear plan before implementing. Some of the things that I have thought are the following:
In order to support both concatenate to list and replace the list, there needs to be a special syntax. I have thought about if no special syntax is used, then by default it concatenates. This would make it exactly as it is now in pytorch-lightning. However, all other list types (except callbacks) replace the list. Furthermore, I haven't thought of any syntax that makes intuitive that works this way. Thus, I am thinking that there will be a special syntax to concatenate. An idea would be the plus sign python script.py \
--foo.people+=A --foo.people.name=one \
--foo.people+=A --foo.people.name=two \
--foo.people+=A --foo.people.name=three In a config file it would work the same way by having at the end of the key the Not having the |
I don't think this is important, as creating lists from config files is well supported (see top post) and uses an intuitive syntax. Adding this custom My proposal is about improving the experience of creating lists from command line, not necessarily about differentiating between concatenation and replacement. If we ignore the latter requirement, it shouldn't need custom notation. |
Having the same features/behavior in both command line and config files has already been asked for. And just for consistency it makes sense to do. See for instance #89 and #113. People do use multiple config files, and currently there is no way to concatenate to a list in a second config file.
Actually, not having a syntax difference would be a breaking change. Suppose you have an argument with type Furthermore, suppose you have a type Adding this syntax will not break any code that uses plain jsonargparse, since this would be a new feature. Certainly this behavior is different than what
Sure, but as I explained it doesn't make sense to have concatenate without being able to replace. Just because the proposal/need is only for concatenate, it is not a good reason to compromise on the design. |
Added append to lists support both from command line and config file #85.
When one wants to pass a list of objects to a parser, this works very well using configs:
(ignore the silly names)
However, for users who do not want or cannot use configs, their only option is to write the entire config through command line:
This is very long to write and error prone.
Pitch
Support the previous by doing:
where the order is important, as the
init_args
apply to the previous item with the same nested key.Additional context:
We are implementing this in Lightning-AI/pytorch-lightning#8815
The text was updated successfully, but these errors were encountered: