rs_
rs_

Reputation: 453

Hydra : how to assign config files from same group to two different fields

Here is my config directory structure,

config
|
--scenes
  |
  -- aaa.yaml
  -- bbb.yaml
  -- ccc.yaml
-- myconfig.yaml
aaa.yaml
--------
field_xxx: "someval"
field_yyy: "someval"
field_zzz: "someval"

bbb.yaml
--------
field_xxx: "someval"
field_yyy: "someval"
field_zzz: "someval"

myconfig.yaml has two fields src_scene and dst_scene. Currently I've hardcoded the fields and values for aaa.yaml and bbb.yaml into myconfig.yaml as follows,

myconfig.yaml
-------
src_scene:
   field_xxx: "someval"
   field_yyy: "someval"
   field_zzz: "someval"

dst_scene:
   field_xxx: "someval"
   field_yyy: "someval"
   field_zzz: "someval"

Ideally, I want to be able to assign these fields values from any of the config files in scenes group. Something like below,

src_scene: scenes/aaa.yaml
dst_scene: scenes/bbb.yaml

What is the right way of achieving this?

Upvotes: 0

Views: 1743

Answers (2)

Fotisk
Fotisk

Reputation: 11

To build up on the previous answer, since I had the same problem, you can just write in your myconfig.yaml file :

myconfig.yaml
------------

defaults:
 - scenes@src_scene : aaa
 - scenes@dst_scene : bbb

If you want to override a value from the cmd line you can also just do scenes@src_scene=ccc

Upvotes: 0

Omry Yadan
Omry Yadan

Reputation: 33686

If you want to use the same config group multiple times, you can use package override.

Read the whole page, but look in particular at the last section.

Upvotes: 1

Related Questions