-
-
Notifications
You must be signed in to change notification settings - Fork 61
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
It seems that one configuration file completely overwrites the parameters of another config file in a subclass init_args when used with multiple config files. It works from the commandline, i.e. --trainer.init_args.<param> will overwrite the trainer <param>, but it doesn't work for multiple configuration files, i.e. a default one and one given on the command line.
I am using pytorch lightning Trainer as an example because it has a lot of arguments, not sure I would actually be subclassing it.
import json
import pytorch_lightning as pl
from jsonargparse import ArgumentParser, namespace_to_dict
from pprint import pprint
config1= {
'trainer': {
'class_path': 'pytorch_lightning.Trainer',
'init_args': {
'max_epochs': 101
}
}
}
config2 = {
'trainer': {
'class_path': 'pytorch_lightning.Trainer',
'init_args': {
'accelerator': 'ddp'
}
}
}
parser = ArgumentParser()
parser.add_argument('--cfg', action=ActionConfigFile)
parser.add_subclass_arguments(pl.Trainer, 'trainer')
args = parser.parse_args([
'--cfg', json.dumps(config1),
'--cfg', json.dumps(config2),
'--trainer.init_args.limit_val_batches', '25',
])I would expect to have
pprint(namespace_to_dict(args))
{'trainer': {
...
'max_epochs': 101,
'accelerator': 'ddp',
'limit_val_batches': 25,
...
}
}But instead I get:
pprint(namespace_to_dict(args))
{'trainer': {
...
'max_epochs': None, #default
'accelerator': 'ddp',
'limit_val_batches': 25,
...
}
}Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request