Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dict config #79

Merged
merged 2 commits into from Nov 26, 2017
Merged

Add dict config #79

merged 2 commits into from Nov 26, 2017

Conversation

abadger
Copy link
Collaborator

@abadger abadger commented Oct 30, 2017

This is inspired by dictConfig from the python stdlib's logging module, version 2.7 and above: https://docs.python.org/2/library/logging.config.html#dictionary-schema-details

The idea is to make it easy to configure the logging subsystem from a config source outside of the program. That way a program can make it possible for the user to configure logging in a config file.

This PR curently has code and tests but no documentation.

Fixes #59

@abadger abadger force-pushed the add-dict_config branch 2 times, most recently from 6db284b to 5640a12 Compare October 30, 2017 02:33
@abadger
Copy link
Collaborator Author

abadger commented Oct 30, 2017

Ahhh... The current version of volutpuous does not support Python-2.6. It looks like only a few minor fixes to voluptuous would be required to make that work but I don't know if they'd take those patches. I've submitted a bug report to ask them if they would be willing to continue 2.6 support or not. If they answer in the negative I'll take a look at how hard it would be to do the schema validation in custom code rather than using voluptuous (something we may have to do someday anyway if twiggy makes it into the standard library.)

@abadger
Copy link
Collaborator Author

abadger commented Oct 30, 2017

Voluptuous issue asking whether they'd consider restoring python-2.6 support: alecthomas/voluptuous#306

@abadger
Copy link
Collaborator Author

abadger commented Nov 13, 2017

Okay, I've gotten the code switched from validating the config schema via voluptuous to validating via a bespoke validation function and updated the unit tests. init and the new code in lib/validators is 100% unittested. Test failure is due to documentation errors. The new section for dict_config() is still being worked on so that's expected. Hopefully I can get that cleaned up the rest of the way this week.

@abadger abadger force-pushed the add-dict_config branch 6 times, most recently from ca0aebd to 1c923d5 Compare November 17, 2017 23:02
@abadger
Copy link
Collaborator Author

abadger commented Nov 17, 2017

Okay, the documentation could probably use some further work (wordsmithing, organization, etc) but this is ready for someone else to review and tell me what is still lacking.

Copy link
Owner

@wearpants wearpants left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, see one note about raising errors on bad dict_config. Will review docs in more depth & tweak a bit. Thanks, this is exciting.

"""
try:
cfg = _validate_config(config)
except ValueError as e:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I think in this case it makes sense to raise... There is no validation for programmatic setup (since there's no clear 'done' state at which to check) so it falls back to internal errors at runtime, but that would be really surprising behavior here IMO

@wearpants wearpants merged commit 297f0b9 into wearpants:master Nov 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants