omry / omegaconf

Flexible Python configuration system. The last one you will ever need.
BSD 3-Clause "New" or "Revised" License
1.91k stars 104 forks source link

Multiple relative interpolation #1077

Closed qmpzzpmq closed 1 year ago

qmpzzpmq commented 1 year ago

as folling from documnet:

from: https://omegaconf.readthedocs.io/en/2.3_branch/usage.html

Interpolations are absolute by default. Relative interpolation are prefixed by one or more dots: The first dot denotes the level of the node itself and additional dots are going up the parent hierarchy. e.g. ${..foo} points to the foo sibling of the parent of the current node.

but how to access the parent of parent of current?

omry commented 1 year ago

Please explain what you mean with an example.

qmpzzpmq commented 1 year ago

I had a yaml file like:

train:
    dataset: 
        mapper: "A"
    prcess_dps "B"
val:
    dataset:
        mapper: ${}
    prcess_dps ${..train.process.dataset}

I would like keep the val.dataset.mapper same with train.dataset.mappser. so the reletive interpolation should be go up to parent levels twice. I don't find anyway to implement it

omry commented 1 year ago
train:
    dataset: 
        mapper: A
    prcess_dps: B
val:
    dataset:
        mapper: ${...train.dataset.mapper}
    prcess_dps: ${..train.prcess_dps}