Add audeer.load_configuration()#195
Open
hagenw wants to merge 11 commits into
Open
Conversation
Contributor
Reviewer's GuideIntroduce audeer.load_configuration() as a unified configuration loader with YAML file + environment variable merging, wire it into the top-level package API, add tests and optional YAML dependency, and adjust install tests to use wrapt instead of PyYAML. Flow diagram for audeer.load_configuration() merging logicflowchart TD
A[Call load_configuration] --> B[Load default_config_file via _load_configuration_file]
B --> C{user_config_files provided?}
C -- no --> D{env_prefix provided?}
C -- yes --> E[Iterate user_config_files and merge with _load_configuration_file]
E --> D
D -- no --> G{validate callable provided?}
D -- yes --> F[Override values with environment via _override_with_environment]
F --> G
G -- yes --> H[Call validate on merged config]
G -- no --> I[Return merged config]
H --> I
subgraph File_loading
B
E
end
subgraph Environment_override
F --> J[For each config key, read env var and parse via _parse_environment_value]
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add
audeer.load_configuration()to provide a unified way for handling configuration files, including providing a default config file, supporting overriding by user config files and by environment variables.The new function can then be reused inside
audbandaudmodeland will solve audeering/audb#485.We need
pyamlto read the configuration files, but to not add a new default dependency we add it as optonal dependency that you need to enable withaudeer[yaml]in order to useaudeer.load_configuration().I also update the unrelated
tests/test_install.pyas it usedpyyamlbefore in the tests. As this is now a dependency ofaudeer, I switched to python-dotenv.