[CLI] Cannot pass init_args to override config file
See original GitHub issue🐛 Bug
Suppose I have a CLI configuration file, but I have no way to modify the Datamodule or Model init_args in it via command line arguments.
To Reproduce
I thought the traceback is clear enough, so I don’t reproduce with a BoringModel. If you really need it, please let me know.
Here is the reproduce steps:
git clone https://github.com/tshu-w/lightning-template.git
conda create -n env python=3.9 && conda activate env && pip install -r requirements.txt
- make sure
run fit --config configs/mrpc.yaml --print_config=skip_null
works fine. run fit --config configs/mrpc.yaml --data.batch_size=64 --print_config=skip_null
raise error.
Traceback
Traceback (most recent call last):
File "/home1/wangtianshu/lightning-template/run", line 33, in <module>
main()
File "/home1/wangtianshu/lightning-template/run", line 20, in main
cli = LitCLI(
File "/home1/wangtianshu/.local/share/conda/envs/template/lib/python3.9/site-packages/pytorch_lightning/utilities/cli.py", line 516, in __init__
self.parse_arguments(self.parser)
File "/home1/wangtianshu/.local/share/conda/envs/template/lib/python3.9/site-packages/pytorch_lightning/utilities/cli.py", line 655, in parse_arguments
self.config = parser.parse_args()
File "/home1/wangtianshu/.local/share/conda/envs/template/lib/python3.9/site-packages/pytorch_lightning/utilities/cli.py", line 230, in parse_args
argv = self._convert_argv_issue_84(classes, k, argv)
File "/home1/wangtianshu/.local/share/conda/envs/template/lib/python3.9/site-packages/pytorch_lightning/utilities/cli.py", line 290, in _convert_argv_issue_84
class_path = passed_args[f"{argv_key}.class_path"]
KeyError: '--data.class_path'
Expected behavior
run fit --config configs/mrpc.yaml --data.batch_size=64 --print_config=skip_null
works correctly.
Environment
- Packages:
- numpy: 1.22.2
- pyTorch_debug: False
- pyTorch_version: 1.11.0+cu113
- pytorch-lightning: 1.5.10
- tqdm: 4.63.0
- System:
- OS: Linux
- architecture:
- 64bit
- ELF
- processor: x86_64
- python: 3.9.7
- version: #219-Ubuntu SMP Tue Aug 11 12:26:50 UTC 2020
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Subclass init_args overwritten with multiple config files #89
It works from the commandline, i.e. --trainer.init_args.<param> will overwrite the trainer <param> , but it doesn't work for multiple ...
Read more >How do I override Git configuration options by command line ...
Yes, you can pass it with -c , like: git -c http.proxy=someproxy clone https://github.com/user/repo.git.
Read more >Overriding the Configuration File from the CLI
The --co option enables you to override the configuration file from the command line, so you can change parameters on the fly as...
Read more >jsonargparse — jsonargparse documentation
The default config files are always parsed first, this means that any command line argument will override its values. It is also possible...
Read more >AWS CLI Configuration Variables - AWS Documentation
The AWS CLI config file, which defaults to ~/.aws/config has the ... will override the credentials located in the profile provided by AWS_PROFILE...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Opened that report in a separate issue @quancs
I thought my problem is relavant to this one (both related with init_args, and may have the same solution), so I posted it in this issue. Anyway, thank you for moving it. ^^