Skip to content

[Bug] --cfg=hydra CLI fails if top-level config is read-only #1461

@Jasha10

Description

@Jasha10

🐛 Bug

Description

The --cfg=hydra flag on the command line fails when the top-level node is read-only

$ cd ~/hydra.git/examples/patterns/write_protect_config_node/
$ python frozen.py
{'baud_rate': 19200, 'data_bits': 8, 'stop_bits': 1}
$ python frozen.py --cfg=hydra
Traceback (most recent call last):
  File "/Users/lappy486/hydra.git/hydra/_internal/utils.py", line 210, in run_and_report
    return func()
  File "/Users/lappy486/hydra.git/hydra/_internal/utils.py", line 378, in <lambda>
    lambda: hydra.show_cfg(
  File "/Users/lappy486/hydra.git/hydra/_internal/hydra.py", line 162, in show_cfg
    cfg = self._get_cfg(
  File "/Users/lappy486/hydra.git/hydra/_internal/hydra.py", line 152, in _get_cfg
    cfg = self.get_sanitized_hydra_cfg(cfg)
  File "/Users/lappy486/hydra.git/hydra/_internal/hydra.py", line 128, in get_sanitized_hydra_cfg
    del cfg[key]
  File "/Users/lappy486/opt/miniconda3/envs/hydra/lib/python3.8/site-packages/omegaconf/dictconfig.py", line 380, in __delitem__
    self._format_and_raise(
  File "/Users/lappy486/opt/miniconda3/envs/hydra/lib/python3.8/site-packages/omegaconf/base.py", line 171, in _format_and_raise
    format_and_raise(
  File "/Users/lappy486/opt/miniconda3/envs/hydra/lib/python3.8/site-packages/omegaconf/_utils.py", line 640, in format_and_raise
    _raise(ex, cause)
  File "/Users/lappy486/opt/miniconda3/envs/hydra/lib/python3.8/site-packages/omegaconf/_utils.py", line 543, in _raise
    raise ex.with_traceback(sys.exc_info()[2])  # set end OC_CAUSE=1 for full backtrace
omegaconf.errors.ReadonlyConfigError: DictConfig in read-only mode does not support deletion
    full_key: baud_rate
    object_type=SerialPort

System information

  • Hydra Version : '1.1.0dev5'
  • Python version : 3.8.8
  • Virtual environment type and version : conda
  • Operating system : MacOs

Metadata

Metadata

Assignees

Labels

In progressWork in progressbugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions