colobas
colobas

Reputation: 31

Is it possible to have a config key be the result of a variable interpolation in Hydra?

Assuming the following config structure:

config.yaml
|-model
|  |--default.yaml
|
|-data
   |--default.yaml

config.yaml :

defaults:
  - model: default
  - data: default

model/default.yaml :

...
x_label: some_label
...

The following doesn't work:

data/default.yaml:

...
loaders:
  ${model.x_label}:
    param1: a
    param2: b
...

Is there a way to make something like this work? Or an equivalent alternative?

Upvotes: 3

Views: 1182

Answers (1)

Jasha
Jasha

Reputation: 7797

Currently this is unspported in Hydra/OmegaConf; values can be interpolations, but keys cannot.

As a workaround, consider the following for your data/default.yaml file:

...
loaders:
  label: ${model.x_label}
  params:
    param1: a
    param2: b
...

Upvotes: 1

Related Questions