jsonargparse
jsonargparse copied to clipboard
Overwriting subconfig retains values from default subconfig
🐛 Bug report
I have a master config that is formed from multiple other sub-configs stored in separate files (one for data, one for architecture etc.). When I specify from the CLI a different version of a sub-config my expectation is that the sub-config gets completely overwritten. Instead, what I got is a merged sub-config between the default and the one provided through the CLI. I believe this is a bug. Otherwise let me know if this intended, and if maybe there is a setting through which we can control the behaviour to overwrite
To reproduce
test.py
from jsonargparse import CLI
from dataclasses import dataclass
@dataclass
class Data:
attribute_1: int
attribute_2: int
@dataclass
class Test:
data: Data
print(CLI(Test, fail_untyped=True))
main_config.yaml
data: data_default.yaml
data_default.yaml
attribute_1: 1
attribute_2: 10
data_new.yaml
attribute_1: 2
python test.py --config main_config.yaml --data data_new.yaml
Expected behavior
I should get an error that says attribute_2 is required but has not been provided.
Instead, i get
Test(data=Data(attribute_1=2, attribute_2=10))
Environment
- jsonargparse version: 4.23.1
- Python version : 3.10.12
- How jsonargparse was installed:
pip install jsonargparse[signatures,typing-extensions]==4.23.1
- OS (e.g., Linux): Ubuntu 22.04.2 LTS