Skip to content

Commit

Permalink
- Disabled dynamic cfg value creation for safety
Browse files Browse the repository at this point in the history
  • Loading branch information
gomezzz committed Jul 26, 2022
1 parent 8bf5394 commit 776796c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion nidn/utils/load_default_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ def load_default_cfg():
os.path.dirname(__file__) + "/resources/", "default_config.toml"
)
with open(path) as cfg:
return DotMap(toml.load(cfg))
# dynamic=False inhibits automatic generation of non-existing keys
return DotMap(toml.load(cfg), _dynamic=False)
2 changes: 1 addition & 1 deletion nidn/utils/validate_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _check_value_ranges(cfg: DotMap):
]

for key in all_positive_list_keys:
if not (all(cfg[key]) > 0.0):
if key in cfg.keys() and not (all(cfg[key]) > 0.0):
raise RuntimeError(f"All elements in {key} must be a positive integer")
for key in all_positive_or_zero_list_keys:
if not (all(cfg[key]) >= 0.0):
Expand Down

0 comments on commit 776796c

Please sign in to comment.