Comments (7)
Thanks for the explanation. I just thought that the behavior should be the same, regardless if the value of the flag gets set to
True
orFalse
.
It should indeed be the same.
Because I just need a "reset" of the flag for the whole config and some child nodes can be
readonly
, I just usedoc.create(oc.to_container(config))
and create a fresh config without any flags.
I agree it'd be good to also have a way to clear flags recursively.
from omegaconf.
It should indeed be the same.
Ahh you're right. I forgot for a moment, that directly set flags have higher priority than the parent flags 🤦♂️ .
from omegaconf.
Although I agree this can be confusing, I'm not sure this is actually a bug.
The way flags work in OmegaConf is that a node inherits its parent's flags except for those that are explicitly set for this node. See code at:
Line 200 in 7dae67e
The order in which flags are set doesn't matter. Whether you do
OmegaConf.set_readonly(config, False)
OmegaConf.set_readonly(config.a, True)
or
OmegaConf.set_readonly(config.a, True)
OmegaConf.set_readonly(config, False)
you will always have is_readonly(config.a)
because the flag is explicitly set for the subconfig node.
I think it'd make sense to add an option to override the child nodes' flags, but in the meantime, my suggestion would be that you write your own function that iterates over children to achieve this.
from omegaconf.
Thanks for the explanation. I just thought that the behavior should be the same, regardless if the value of the flag gets set to True
or False
.
Because I just need a "reset" of the flag for the whole config and some child nodes can be readonly
, I just used oc.create(oc.to_container(config))
and create a fresh config without any flags.
from omegaconf.
Because I just need a "reset" of the flag for the whole config and some child nodes can be readonly, I just used oc.create(oc.to_container(config)) and create a fresh config without any flags.
IIRC You can reset the value of a node by setting the flag value on that node to None.
If you want to do it recursively, maybe it's better to introduce a new reset_flag function instead of overloading set_flag.
from omegaconf.
I would be happy with both options. I just need a config with no flags, therefor its not important, if the value is None
or False
. A reset_flag
function would be cool, too, but would do the same job as set_flag("reaonly", None)
.
from omegaconf.
Yeah I think a recursive set_flag()
is more generic and powerful than a recursive reset_flag()
.
from omegaconf.
Related Issues (20)
- Pre-commit hooks are not working correctly
- Default Not Being Set HOT 3
- Work with dots in keynames HOT 6
- Unexpected behavior for multiline-strings HOT 16
- `OmegaConf.missing_keys(cfg)` may fail if contained customized resolver field that the depends on some missing fields. HOT 5
- Escaped resolver modifying `_root_` doesn't work HOT 2
- Improve error message for relative interpolations HOT 1
- Make `select` and `oc.select` more robust HOT 2
- Question : why we need "???" and what's for ? HOT 2
- Add function to check if key exists HOT 4
- Interpolations that resolve to missing value `???` don't get passed to resolvers HOT 3
- `OmegaConf.resolve` should crash when a resolver input is missing
- [Feature Request] integration between omegaconf and AWS Sagemaker Estimator's hyperparameters
- Add support for dataclasses._MISSING_TYPE
- Resolve relative variables inside of a list HOT 2
- readthedocs: No such file or directory: 'java'
- Node interpolation not working HOT 3
- ImportError: cannot import name 'get_ref_type' from 'omegaconf._utils' HOT 1
- Use `yaml.CSafeLoader` whenever possible for speedups
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from omegaconf.