omni-us / jsonargparse

Implement minimal boilerplate CLIs derived from type hints and parse from command line, config files and environment variables
https://jsonargparse.readthedocs.io
MIT License
322 stars 47 forks source link

Overwrite subconfig arguments #418

Closed rusmux closed 4 months ago

rusmux commented 12 months ago

🚀 Feature request

Allow to overwrite subconfig arguments. For example:

evaluate.yaml:

model: model.yaml
data: path/to/data

model.yaml:

class_path: path.to.Model
init_args:
  a: 1
  b: 2
  c: 3
  d: 4
  e: 5

I want to create evaluate_2.yaml with e argument of the model equal to something else. It would be nice to do this like this:

model: model.yaml
  init_args:
    e: 6

I can do this from the CLI by passing an argument, but I would also like to do it using config.

Probably something similar has already been suggested, but I got lost in numerous problems here and in Lightning, so I would appreciate it if you could help me. Thanks!

Motivation

To avoid duplicating configs.

function2-llx commented 11 months ago

Seemingly related to https://github.com/omni-us/jsonargparse/issues/221.

rusmux commented 11 months ago

Yes, thank you! As indicated there, this can be done from the CLI, but there are cases when it is inconvenient to specify arguments from the CLI, for example, if it is a list of some strings. I can create a separate file in which I would override this argument, but now instead of 1 file (evaluation_2.yaml) I get 2 files (evaluation_2.yaml and model_2.yaml). I think it's more convenient to put this argument directly in evaluation_2.yaml.

mauvilsa commented 4 months ago

Closing this in favor of #221