Hydra: Use `# @package _global_` only on a part of a file

487 Views Asked by At

I would like to use the # @package _global_ directive only on a specific part of my config. E.g. here I want my datamodule to be able to override an attribute of the trainer. Is there any way to do that?

Things I tried:

  1. Using # @package _global_ at the beginning but I don't want to change the file default.yaml (it's imported by other files).
  2. Using trainer@_global_
  3. Using /trainer
  4. Using _self_@_global_ (but it seems that it's not allowed and would apply all the rest of the config to _global_).

Tree:

conf
├── config.yaml
├── datamodule
│   ├── default.yaml
│   └── my_datamodule.yaml
└── trainer
    └── single_gpu.yaml

conf/datamodule/default.yaml

n_train_samples: null

conf/datamodule/my_datamodule.yaml

defaults:
  - default
  - _self_

batch_size: 32

# @package _global_
trainer:
    val_check_interval: 99999

Expected behaviour: datamodule: n_train_samples: null batch_size: 32 trainer: val_check_interval: 99999 gpus: 1

Actual behaviour: datamodule: n_train_samples: null batch_size: 32 trainer: val_check_interval: 99999999999999999 trainer: gpus: 1

0

There are 0 best solutions below