facebookresearch / hydra

Hydra is a framework for elegantly configuring complex applications
https://hydra.cc
MIT License
8.61k stars 619 forks source link

[Feature Request] Relative interpolation support #1220

Closed atemate closed 3 years ago

atemate commented 3 years ago

šŸš€ Feature Request

Hey! I'm using hydra as a configuration for my MLOps project, and I usually need to address some elements that are deeply nested but close to current element. For example, consider the following config:

job:
  volumes:
    ...
    results:
      ...
      paths:
        config_path: path/to/config
        config_name: ${job.volumes.results.paths.config_path}/run.yaml

Here, the element job.volumes.results.paths.config_name wants to access the relative element config_path, and we need to define the whole path ${job.volumes.results.paths.config_path} whereas it would be shorter (and more readable) to define it as a relative element, for example: ${.config_path}.

I realize there are some problems with this notation:

  1. it might be not obvious what it means,
  2. if we follow python packaging analogy, then ${..element} should mean "level-up element", or ${...element} - "2 times level-up element", which perhaps is even less obvious. Or not? :thinking:

Let's discuss if this feature is an over-complication or a handy thing.

omry commented 3 years ago

Hi @yartem! This is a feature request for OmegaConf, not Hydra. Luckily - I already filed this exact feature request here.

Furthermore it's actually already implemented in the master branch (which will be released as OmegaConf 2.1 along with Hydra 1.1).

You can try it out with by installing the OmegaConf dev release but generally speaking there could be incompatibilities with Hydra 1.0 (I am not aware of any, but it's not tested with that version).

The latest dev release is 2.1.0.dev13, please be advised that those are not pretending to have a stable API and things there may come and go. (even though they are always passing the tests in master when I release them).