Skip to content

Commit

Permalink
Error on invalid config data (#855)
Browse files Browse the repository at this point in the history
* Detection of an invalid config value triggers an error rather than just a quiet debug log.

* Update changelog with PR number.

* Tweak naming and comments.

Co-authored-by: Bradley Dice <bdice@bradleydice.com>
  • Loading branch information
vyasr and bdice committed Nov 6, 2022
1 parent 6390077 commit 7f2297d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Changed
- Rather than searching upwards until the root, ``load_config`` will only load configuration files in the specified directory, which is assumed to be a project directory, as well as the user's home directory (#711).
- Changed the ``root`` parameter to ``path`` in the ``signac.get_project`` and ``signac.init_project`` functions and corresponding ``Project`` methods (#757, #758).
- The prefix argument to ``$ signac view`` is now optional and can be provided with ``-p/--prefix`` (#653, #774).
- Detection of an invalid config will raise an error rather than a debug log (#855).

Removed
+++++++
Expand Down
12 changes: 6 additions & 6 deletions signac/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ def _read_config_file(filename):
except (OSError, ConfigObjError) as error:
raise ConfigError(f"Failed to read configuration file '{filename}':\n{error}")
verification = config.verify()
# config.verify() returns True if everything succeeded, but if the
# validation failed it will return a dictionary of invalid results. We
# cannot simply check for a truthy value here since a non-empty dict will
# evaluate to True.
if verification is not True:
# TODO: In the future this should raise an error, not just a
# debug-level logging notice.
logger.debug(
"Config file '{}' may contain invalid values.".format(
os.path.abspath(filename)
)
raise ConfigError(
f"Config file '{os.path.abspath(filename)}' may contain invalid values."
)
return config

Expand Down

0 comments on commit 7f2297d

Please sign in to comment.