`InterpolationKeyError`: Cannot use basic variable interpolation
See original GitHub issueš Bug
Description
Running into an issue trying to use variable interpolation in the most basic case.
Checklist
- I checked on the latest version of Hydra
- I created a minimal repro (See this for tips).
To reproduce
### dataset.yaml ###
dataset:
cwd: ${hydra:runtime.cwd}
data_dir: ../${cwd}/data
### From testing_configs.py ###
print(cfg['dataset'].data_dir)
which produces the following:
...
raise InterpolationKeyError(f"Interpolation key '{inter_key}' not found")
omegaconf.errors.InterpolationKeyError: Interpolation key 'cwd' not found
Expected Behavior
I expect the path to be correctly printed:
/path/to/cwd/data/
System information
- Hydra Version :
1.2.0
/omegaconf==2.2.3
- Python version :
3.8.13
- Virtual environment type and version :
conda
(usedpip install hydra-core āupgrade
) - Operating system : macOS 12.6
Additional context
Iām using a dataclass
spec file with a ConfigStore
instance.
Side note:
Why do I need the import statement from folder.file import Dataset
in testing_configs.py
file? I get a NameError
otherwise.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Interpolation in Hydra's defaults list cause and error
Interpolation Keys in the Defaults List cannot reference values in the Final Config Object (it does not yet exist). In particular, it isĀ ......
Read more >dir interpolation from hydra into job config is not working #240
KeyError : "str interpolation key 'experiment.base_dir' not found". Is there any way I can change the hydra config based on current .yaml orĀ ......
Read more >Python String Interpolation - Towards Data Science
String interpolation is a process of injecting value into a placeholder (a placeholder is nothing but a variable to which you can assign...
Read more >omegaconf.errors.interpolationresolutionerror: valueerror ...
Hi I am wondering if it is possible to use hydra: namespace in the sweep. ... The problem is that I can't resolve...
Read more >PEP 498 ā Literal String Interpolation
F-strings provide a way to embed expressions inside string literals, using a minimal syntax. It should be noted that an f-string is really...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Youāll probably need
${.cwd}/../..
to get two levels up, not../${.cwd}
.If
${.cwd}
is/foo/bar/baz
then${.cwd}/../..
will be equivalent to/foo/bar/baz/../..
while../${.cwd}
is equivalent to..//foo/bar/baz
(which is probably not what you want).Thatās awesome! Thanks so much for helping me understand this ā everything works perfectly!