# Buggy code
def set_config(self, cfg: DictConfig) -> None:
    assert cfg is not None
    OmegaConf.set_readonly(cfg.hydra, True)
    assert OmegaConf.get_type(cfg, "hydra") == HydraConf
    self.cfg = OmegaConf.masked_copy(cfg, "hydra")  # type: ignore


# Traceback (omegaconf.errors.ConfigKeyError)
Traceback (most recent call last):
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/hydra/_internal/utils.py", line 197, in run_and_report
return func()
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/hydra/_internal/utils.py", line 271, in <lambda>
lambda: hydra.run(
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/hydra/_internal/hydra.py", line 105, in run
return run_job(
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/hydra/core/utils.py", line 122, in run_job
ret.return_value = task_function(task_cfg)
File "/home/mtadmin/projects/debug_hydra/interpolation_jobdir/test.py", line 16, in run
print("c", config.c)
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/dictconfig.py", line 315, in __getattr__
self._format_and_raise(key=key, value=None, cause=e)
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/base.py", line 95, in _format_and_raise
format_and_raise(
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/_utils.py", line 555, in format_and_raise
raise_(ex, cause)
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/_utils.py", line 548, in raise_
raise ex
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/dictconfig.py", line 313, in __getattr__
return self._get_impl(key=key, default_value=DEFAULT_VALUE_MARKER)
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/dictconfig.py", line 377, in _get_impl
return self._resolve_with_default(
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/basecontainer.py", line 56, in _resolve_with_default
resolved = self._resolve_interpolation(
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/base.py", line 370, in _resolve_interpolation
return self._resolve_simple_interpolation(
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/base.py", line 344, in _resolve_simple_interpolation
self._format_and_raise(key=inter_key, value=None, cause=e)
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/base.py", line 95, in _format_and_raise
format_and_raise(
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/_utils.py", line 555, in format_and_raise
raise_(ex, cause)
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/_utils.py", line 548, in raise_
raise ex
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/base.py", line 335, in _resolve_simple_interpolation
value = resolver(root_node, inter_key)
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/omegaconf.py", line 335, in caching
cache[key] if key in cache else resolver(*OmegaConf._tokenize_args(key))
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/hydra/core/utils.py", line 150, in <lambda>
lambda path: OmegaConf.select(cast(DictConfig, HydraConfig.get()), path),
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/omegaconf.py", line 531, in select
format_and_raise(node=cfg, key=key, value=None, cause=e, msg=str(e))
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/_utils.py", line 623, in format_and_raise
raise_(ex, cause)
File "/home/mtadmin/miniconda3/envs/debug_hydra/lib/python3.8/site-packages/omegaconf/_utils.py", line 548, in raise_
raise ex
omegaconf.errors.ConfigKeyError: str interpolation key 'a' not found
full_key: hydra.job.override_dirname
reference_type=Optional[HydraConf]
object_type=HydraConf

# Fixed code
def set_config(self, cfg: DictConfig) -> None:
    assert cfg is not None
    OmegaConf.set_readonly(cfg.hydra, True)
    assert OmegaConf.get_type(cfg, "hydra") == HydraConf
    # THis is emulating a node that is hidden.
    # It's quiet a hack but it will be much better once
    # https://github.com/omry/omegaconf/issues/280 is done
    # The motivation is that this allows for interpolations from the hydra node
    # into the user's config.
    self.cfg = OmegaConf.masked_copy(cfg, "hydra")  # type: ignore
    self.cfg.hydra._set_parent(cfg)  # type: ignore