Skip to content

Lightning 1.5 auto adds "fit" key to top level of CLI config breaking jsonargparse configuration check #10460

@rbracco

Description

@rbracco

🐛 Bug

Since the CLI subcommands were added in 1.5 my config files break after running because a new top level key "fit" is added. I run the command python train_scripts/trainer.py fit --config config.yaml as recommended in the docs and this runs properly, but the config.yaml is overwritten and goes from the format

trainer:
   gpus: 1
data:
   num_workers: 8

to having it all nested under the 'fit' key as follows:

fit:
   trainer:
       gpus: 1
   data:
       num_workers: 8

then when I run python train_scripts/trainer.py fit --config config.yaml again it fails with jsonargparse error message: trainer.py: error: Configuration check failed :: Key "data.val_manifest" is required but not included in config object or its value is None., presumably because that value is now found under "fit.data.val_manifest".

To Reproduce

Expected behavior

Running python train_scripts/trainer.py fit --config config.yaml should not clobber the config file. Expected behavior in the docs is that config files that come after the subcommand should not need to have top-level subcommand keys in the config

image

Environment

  • PyTorch Lightning Version (e.g., 1.5.1):
  • PyTorch Version (e.g., 1.10.0)
  • Python version: 3.8.10
  • OS (e.g., Linux): Linux
  • CUDA/cuDNN version: 11.3
  • How you installed PyTorch (conda, pip, source): pip
  • If compiling from source, the output of torch.__config__.show():
  • Any other relevant information: I updated both pytorch-lightning[extras] and jsonargparse

Metadata

Metadata

Assignees

Labels

argparse (removed)Related to argument parsing (argparse, Hydra, ...)bugSomething isn't workinghelp wantedOpen to be worked on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions