-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible edge case: interpolation to key containing a colon #680
Comments
Nice catch. OmegaConf never supported it and there have been no user reports about it. |
In case someone runs into this issue, there are at least a few workarounds: # Workaround 1: create a variable to hold the key name
cfg = OmegaConf.create({"fo:o": 123, "bar": "${${bar_ref}}", "bar_ref": "fo:o"})
# Workaround 2: use `oc.decode` (@omry so actually it *is* useful with literal strings!)
cfg = OmegaConf.create({"fo:o": 123, "bar": "${${oc.decode:'fo:o'}}"})
# Workaround 3: use a "select" resolver to manually select arbitrary nodes (maybe later we'll have `oc.select`)
OmegaConf.register_new_resolver("select", lambda key, _parent_: OmegaConf.select(_parent_, key))
cfg = OmegaConf.create({"fo:o": 123, "bar": "${select:'fo:o'}"}) |
I think #687 is addressing this. |
@Jasha10, if you agree - let's close this. |
It adds documentation. |
Oh, got it :) |
It is not uncommon to see config files that contain a value with a colon, e.g.
"<ip_address>:<port_number>"
. It is probably much less common to see a colon as part of a key in a config file. An edge case can arise when interpolating to a key that contains a colon, since OmegaConf uses colons for its resolver syntax.Here is what will happen if you try to do this:
$ python tmp.py Traceback (most recent call last): ... omegaconf.errors.UnsupportedInterpolationType: Unsupported interpolation type fo full_key: bar object_type=dict
If a resolver is registered with a name that equals the part of the key before the colon, you will get this behavior:
I am posting this issue so that there will be documentation for this possible edge case.
The text was updated successfully, but these errors were encountered: