Search code examples
fb-hydraomegaconf

How to reuse a package multiple times in a config?


I have a general camera config yaml, where the only thing that usually changes between specific cameras is the IP address. Some fields (in the following example fps) remain the same.

Can I do something like this in Hydra/OmegaConf?

any_camera.yaml

any_camera:
  stream_url: ???
  fps: 25

all_cameras.yaml

all_cameras:
  cam1:
    @{any_camera}
    stream_url: rtsp://10.0.0.1

  cam2:
    @{any_camera}
    stream_url: rtsp://10.0.0.2


Solution

  • I can see two potential options:

    1. In Hydra you can try: extending configs and select_multiple_configs_from_config_group

    Basically you could have cam1 and cam2 both extend from any_camera and have specific overrides. Then in all_cameras.yaml, you can select multiple config groups to have the config list.

    1. You can also look into omegaconf's node interpolation. But that might require you change the cam config's structure.