jsonargparse icon indicating copy to clipboard operation
jsonargparse copied to clipboard

Support for a list of nested objects

Open memray opened this issue 2 years ago • 1 comments

Hi there,

Great tool! I wonder if it is possible to load/dump configs as a list of nested objects/dataclasses, like the data shown below? It's quite common for ML projects. Thanks! https://github.com/OpenNMT/OpenNMT-py/blob/master/data/features_data.yaml

image

memray avatar Sep 17 '23 04:09 memray

Types like list[<subtype>] are supported. The subtype could be simple, like an int, or complex like a dataclass or a base class to accept subclasses. See for example pytorch lightning's callbacks (LightningCLI is jsonargparse under the hood). The config above doesn't look like a list. Looks more like nested dataclasses, which are also supported.

Note that jsonargparse was developed based on machine learning needs and most of its users are from this community. Depending on what you want, I could advice how to best proceed. Feel free to ask.

mauvilsa avatar Sep 18 '23 05:09 mauvilsa