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

Fix bug with merging configuration files #65

Merged
merged 4 commits into from
Jul 18, 2018
Merged

Fix bug with merging configuration files #65

merged 4 commits into from
Jul 18, 2018

Conversation

jlowin
Copy link
Member

@jlowin jlowin commented Jul 18, 2018

There is a function in collections.py that merges two dictionaries, and is used to load a user configuration into an existing default configuration.

The basic logic is that it iterates over each key of the user config, and if that key has a non-dict value, it updates that key in the default config with the user value. However, if the key is a dict, then it recurses into that dict and performs a nested merge. The idea is that this allows merging of nested dictionaries without forcing the user dict to have every key in the default dict.

However, the merge function only recursed if isinstance(config, dict) was True... and Configs are not, in fact, dicts. This resulted in very bad merges whenever a user config was present that was at all different from the default config, since the merge function wouldn't treat the config as a dict and do a nested merge.

This PR adjusts the merge function to test for isinstance(config, MutableMapping), adds merge unit tests, and also adds a unit test to make sure user configs are loaded appropriately.

@jlowin jlowin requested a review from cicdw as a code owner July 18, 2018 21:49
@jlowin
Copy link
Member Author

jlowin commented Jul 18, 2018

Oh, and this also stops the eager generation of user configuration files, which was creating some issues with stale files in local testing and testing on prefect server (due to an unrelated issue).

Copy link
Member

@cicdw cicdw left a comment

Choose a reason for hiding this comment

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

LGTM

@jlowin jlowin merged commit 726868e into master Jul 18, 2018
@jlowin jlowin deleted the fix-manifest branch July 19, 2018 01:50
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