-
Notifications
You must be signed in to change notification settings - Fork 2
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
Options to load and save states #197
Conversation
|
- refactor: simplify coco_runner arguments (for testing) - Add internal endpoints and client commands to save and load endpoints. New commands / internal endpoints: - save-state - load-state - saved-states Parts of the state configured to be excluded from resets are also excluded from being loaded from a previously loaded state. But they do get saved. BREAKING CHANGE: The config variable 'storage_path' is not a file anymore, but a directory. The state is saved there under the name 'active' and saved states are added here as well. If you are updating your coco instance, you have to manually move the persistent state from 'storage_path' to 'storage_path'/active.
- blacken scripts - add check to travis CI
Metrics server doesn't work with prometheus-client 0.8. Needs to get fixed.
self._name_active_state = "active" | ||
|
||
# List saved states on disk | ||
p = Path(self._storage_path).glob("**/*") |
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.
The Path()
here might be redundant since _storage_path
seems to be guaranteed to be PathLike.
However, it also does not seem to hurt if it is there. =)
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.
Hm, I tried that, but self._storage_path
was a str
.
|
coco/state.py
Outdated
for excluded in self.exclude_from_reset: | ||
if excluded.startswith(path): | ||
if len(path) == 0: | ||
excluded = excluded[len(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.
If len(path) is 0, is this not excluded = excluded?
if path_first in state: | ||
self._exclude_paths(path_first, state[path_first]) | ||
if excluded in state: | ||
del state[excluded] |
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.
You can do all this in-place because python allows you to pass references to dictionaries?
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.
yes, right?
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.
Yeah, that is right, it just always catches me off-guard!
Are dict
s the only object this applies to?
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.
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.
Man, this is such a big change!
The main things look good. You are very thorough with your error checks, and I feel more comfortable with there being tests.
I am curious about what the use-case is for excluded
?
|
Thanks for the thorough review. I think I addressed all the comments. |
With this, cocos state can be written to disk using
and later restored again with
See all saved states with
BREAKING CHANGE: the state path in the config is not a file but a directory now. Move the state in the coco installation from
/old/location
to/old/location/active
(or replace it with an empty directory).Closes #192