Fix for applying logging configurations using the a TOML configuration file #3237
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Configuring logging using the "logging" session of the TOML configuration file throws an exception because the
logging
library tries to write to a frozen dictionary. This PR solves the issue by unfreezing the dictionary before passing it tologging.dictConfig
.Motivation and Context
Starting from version
2.8.11
, the logging section of the configuration file is loaded into frozen a dictionary which is then passed to thelogging.dictConfig
when using the TOML parser. However,logging.dictConfig
expects a mutable dictionary and tries to overwrites some of its keys, resulting in an exception. In practice that means we cannot use the TOML configuration file to configure logging.This problem has been mentioned in the issue #2879
Have you tested this? If so, how?
Manually tested the changes and added a new test case here to replicate the scenario in which the
master
branch would throw an error.