From c64a9db019675bf300ef2512173b96de2240446b Mon Sep 17 00:00:00 2001 From: Matteo Voges Date: Tue, 26 Sep 2023 10:51:37 +0200 Subject: [PATCH] docs: add example for recursive --- docs/source/usage.rst | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/docs/source/usage.rst b/docs/source/usage.rst index 7f63b19a7..fe429e425 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -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: @@ -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