-
Notifications
You must be signed in to change notification settings - Fork 133
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
closed CacheAdapter
#847
Conversation
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 100% sure this is the right solution...
|
||
def run_before_graph_execution(self, *, graph: HamiltonGraph, **kwargs): | ||
"""Set `cache_vars` to all nodes if received None during `__init__`""" | ||
self.cache = shelve.open(self.cache_path) |
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.
Something feels wrong about this. Aren't we just opening it again? Feels like it should:
- Open during
init
- Run during execution
- Close at the end
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.
well, that was the previous behavior... I want to have .close()
somewhere for safety, but putting it in run_after_graph_execution
means you can only run it once
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.
Won't it just open again? Maybe:
- Open/close during
__init__
- Open during
run_before_graph_execution
- Run
- Close at
run_after_graph_execution
?
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 think that's what Thierry just did here?
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.
Ahh yes, my bad
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.
Ship it! Sorry misunderstood a bit. This looks good.
The
CacheAdapter()
would successfully run for the first execution, and fail on subsequent ones. This is because the cache was opened on__init__()
(needs to read some attributes at instantiation) and closed "after graph execution".Changes
cache is now opened and closed at
__init__()
cache is opened "before graph execution" and closed "after graph execution" for satefy