-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
🐛 Bug
Hi! I'm not sure this is actually a bug or if the one doing something wrong, but here's the problem.
I'm using OmegaConf’s variable interpolation to link one parameter in the configuration file to a second one, which I want to provide with the command line. The problem is that, when using the command line to provide one of the two parameters, the second one, linked to the first one with variable interpolation, doesn't change.
To Reproduce
config.yaml
foo: default_value
bar: ${foo}main.py
from pytorch_lightning.utilities.cli import LightningCLI
class MyLightningCLI(LightningCLI):
def add_arguments_to_parser(self, parser):
parser.add_argument("--foo", type=str)
parser.add_argument("--bar", type=str)
if __name__ == "__main__":
cli = MyLightningCLI(parser_kwargs={"parser_mode": "omegaconf"})- Run
python main.py fit \
--config=config.yaml \
--foo=some_value \
--print_config- Result
The result of this is that the foo parameter is equal to the value assigned with the command line, some_value, but the bar parameter isn't, and it is instead keeping its default value set in the config file (default_value).
seed_everything: null
trainer:
logger: true
checkpoint_callback: null
...
foo: some_value
bar: default_value
...Expected behavior
I expected the bar parameter to be equal to the foo parameter, that is to have the value some_value:
seed_everything: null
trainer:
logger: true
checkpoint_callback: null
...
foo: some_value
bar: some_value
...Environment
- PyTorch Lightning Version (e.g., 1.5.0): 1.6.4
- PyTorch Version (e.g., 1.10): 1.10.2
- Python version (e.g., 3.9): 3.9
- OS (e.g., Linux): Mac
- GPU models and configuration: None (CPU)
- How you installed PyTorch (
conda,pip, source):pip