-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**JobDefinition:** * New checkpointer_config section to allow configuring or replacing the default Checkpointer implementation. * Exception will be raised if extension_directories entry is not a valid path. * Exception will be raised if extension_directories entry is not a directory. * Warning will be displayed if extension_directories entry is not a valid package (is a dir, but is missing __init__.py). * Warning will be displayed if importing a module found in any extension_directories, including default dirs, results in an exception. The offending module will be skipped and module discovery + import will continue. **Misc:** * Changed behavior of -j and --jobdef arg to interpret path based on CWD, rather than w/ respect to the .py file where Flowmancer().start() is invoked.
- Loading branch information
Showing
12 changed files
with
237 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[bumpversion] | ||
current_version = 0.5.7 | ||
current_version = 0.6.0 | ||
files = flowmancer/version.py pyproject.toml |
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,3 +1,3 @@ | ||
from . import checkpoint, extensions, loggers | ||
from . import checkpointer, extensions, loggers | ||
from .flowmancer import Flowmancer | ||
from .jobdefinition import file |
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# noqa: F401 | ||
# Ensure implementations are registered | ||
from . import file | ||
from .checkpointer import CheckpointContents, Checkpointer, NoCheckpointAvailableError, checkpointer | ||
|
||
__all__ = ['Checkpointer', 'CheckpointContents', 'NoCheckpointAvailableError', 'checkpointer'] |
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,33 @@ | ||
import os | ||
import pickle | ||
from pathlib import Path | ||
|
||
from .checkpointer import CheckpointContents, Checkpointer, NoCheckpointAvailableError, checkpointer | ||
|
||
|
||
@checkpointer | ||
class FileCheckpointer(Checkpointer): | ||
checkpoint_dir: str = './.flowmancer' | ||
|
||
def write_checkpoint(self, name: str, content: CheckpointContents) -> None: | ||
cdir = Path(self.checkpoint_dir) | ||
if not os.path.exists(cdir): | ||
os.makedirs(cdir, exist_ok=True) | ||
tmp = cdir / (name + '.tmp') | ||
perm = Path(self.checkpoint_dir) / name | ||
with open(tmp, 'wb') as f: | ||
pickle.dump(content, f) | ||
if os.path.isfile(perm): | ||
os.unlink(perm) | ||
os.rename(tmp, perm) | ||
|
||
def read_checkpoint(self, name: str) -> CheckpointContents: | ||
checkpoint_file = Path(self.checkpoint_dir) / name | ||
if not checkpoint_file.exists(): | ||
raise NoCheckpointAvailableError(f'Checkpoint file does not exist: {checkpoint_file}') | ||
return pickle.load(open(checkpoint_file, 'rb')) | ||
|
||
def clear_checkpoint(self, name: str) -> None: | ||
cfile = Path(self.checkpoint_dir) / name | ||
if os.path.isfile(cfile): | ||
os.unlink(cfile) |
Oops, something went wrong.