-
-
Notifications
You must be signed in to change notification settings - Fork 881
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
feat: Make startup scripts idempotent #729
feat: Make startup scripts idempotent #729
Conversation
Cloud you also run isort startup_scripts/*py startup_scripts/startup_script_utils/*py
black startup_scripts/*py startup_scripts/startup_script_utils/*py |
41f24c6
to
d7d7b1e
Compare
Blacked and sorted. |
852bc83
to
61f7f6c
Compare
72a4206
to
a652f47
Compare
Hmm mypy linting fails same as in my other PR in which I fixed that in this commit. If we accept #730 and merge to develop I can then rebase this PR. |
a652f47
to
9be7b0e
Compare
Looks OK to me. |
6a08f45
to
9be7b0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on what criteria did you decide what the match_params
should contain?
Thanks for the PR. That's truely an enhancement and I believe you have found an elegant solution. |
Co-authored-by: Christian Mäder <[email protected]>
I've analyzed deeply all the models and it turned out that 90% of the cases the "name" and "slug" parameters are enough to select an object. |
Related Issue:
New Behavior
This PR makes sure that startup scripts won't crash on subsequent runs if some of the attributes of a given object have been changed in the database since first run of the scripts.
New function has been introduced to separate the matching_params which uniquely identify given object from other non-relevant fields provided in the params dictionary.
Contrast to Current Behavior
Currently the get_or_create method tries to get the object matching all fields provided in YAML initializer.
Problem arises when after initial object creation some of the fields are changed in the database, e.g.
Fields that make a unique match on an object are set in the match_params list on a per script basis, with a default value of ["name", "slug"] if not specified.
Discussion: Benefits and Drawbacks
Above section sums up the motivation and advantages of this PR. This change is backwards compatible.
Changes to the Wiki
n/a
Proposed Release Note Entry
Feature: Make subsequent startup scripts runs idempotent.
Double Check
develop
branch.