Skip to content

Commit

Permalink
docs: add example for recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoVoges committed Sep 26, 2023
1 parent 0d8a767 commit c64a9db
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,9 +539,10 @@ Configuration flags
-------------------

OmegaConf support several configuration flags.
Configuration flags can be set on any configuration node (Sequence or Mapping). if a configuration flag is not set
Configuration flags can be set on any configuration node (Sequence or Mapping). If a configuration flag is not set
it inherits the value from the parent of the node.
The default value inherited from the root node is always false.
To avoid this inhertence and set a flag explicitly to all children nodes, specify the option `recursive=True`.

.. _read-only-flag:

Expand Down Expand Up @@ -570,6 +571,17 @@ You can temporarily remove the read only flag from a config object:
>>> conf.a.b
20

Example using `recursive=True`:

.. doctest:: loaded

>>> conf = OmegaConf.create({"a": {"b": 10}})
>>> OmegaConf.set_readonly(conf.a, True)
>>> OmegaConf.set_readonly(conf, False, recursive = True)
>>> conf.a.b = 20
>>> conf.a.b
20

.. _struct-flag:

Struct flag
Expand Down

0 comments on commit c64a9db

Please sign in to comment.