-
Notifications
You must be signed in to change notification settings - Fork 329
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
Improve drift detection perf, tests, and add some typehints #1186
Conversation
session: neo4j.Session, | ||
query_directory: str, | ||
state_serializer: StateSchema, | ||
storage, |
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.
Not adding a typehint here because it seems like we're doing this ducktyping thing where we expect the storage
object to have a write() function and other methods but I don't want to necessarily restrict it to just the existing storage.FileSystem
object.
@@ -92,10 +96,12 @@ def compare_states(start_state, end_state): | |||
:return: list of tuples of differences between states in the form (dictionary, State object) | |||
""" | |||
differences = [] | |||
# Use set for faster membership check | |||
start_state_results = {tuple(res) for res in start_state.results} |
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.
Main change of this PR. Spend more memory for faster lookup.
continue | ||
drift = [] | ||
drift: List[Union[str, List[str]]] = [] |
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.
I'm not a fan of how the list can have more than one type (and mypy isn't particularly happy about this either) but I don't want to break anything
Uses a set membership check instead of iterating through each item in the list of results to detect drift. Adds unit test to ensure order of results does not matter in the drift detection check. Also adds some typehints.
Uses a set membership check instead of iterating through each item in the list of results to detect drift.
Adds unit test to ensure order of results does not matter in the drift detection check.
Also adds some typehints.