This repository has been archived by the owner on Dec 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable state dumping and loading (#40)
* Add dumping/loading * Add more dumping tests * Remove hash disclaimer * Add --no-compile flag to test_plugin * Set pylint min-public-methods to 1
- Loading branch information
Showing
12 changed files
with
423 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
[FORMAT] | ||
max-line-length=150 | ||
|
||
[BASIC] | ||
min-public-methods=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"""Dumping utilities.""" | ||
|
||
import multiprocessing | ||
|
||
import dill as pickle | ||
|
||
from .util import DumpOn | ||
|
||
class Dumper: | ||
"""Class for dumping objects.""" | ||
|
||
def __init__(self, dumpable): | ||
"""Specify the `dumpable` object to be dumped.""" | ||
|
||
self.dumpable = dumpable | ||
|
||
self.dump_path: str = None | ||
"""Where to dump.""" | ||
|
||
self.dump_on: DumpOn = None | ||
"""When to dump.""" | ||
|
||
def __write_file(self, path): | ||
"""Writes the dump to disk.""" | ||
with open(path, "wb") as file: | ||
pickle.dump(self.dumpable, file) | ||
|
||
def dump(self, path: str=None): | ||
"""Dump to `path`.""" | ||
path = path or self.dump_path | ||
assert path, "No dump_path defined" | ||
print("Dumping Devnet to:", path) | ||
|
||
multiprocessing.Process( | ||
target=self.__write_file, | ||
args=[path] | ||
).start() | ||
# don't .join(), let it run in background |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.