-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fd311d0
commit 1846145
Showing
2 changed files
with
85 additions
and
5 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
66 changes: 66 additions & 0 deletions
66
parsl/tests/test_checkpointing/test_python_checkpoint_exceptions.py
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,66 @@ | ||
import contextlib | ||
import os | ||
|
||
import pytest | ||
|
||
import parsl | ||
from parsl import python_app | ||
from parsl.config import Config | ||
from parsl.dataflow.memoization import BasicMemoizer | ||
from parsl.executors.threads import ThreadPoolExecutor | ||
|
||
|
||
class CheckpointExceptionsMemoizer(BasicMemoizer): | ||
def filter_for_checkpoint(self, app_fu): | ||
# checkpoint everything, rather than selecting only futures with | ||
# results, not exceptions. | ||
|
||
# task record is available from app_fu.task_record | ||
assert app_fu.task_record is not None | ||
|
||
return True | ||
|
||
|
||
def fresh_config(): | ||
return Config( | ||
memoizer=CheckpointExceptionsMemoizer(), | ||
executors=[ | ||
ThreadPoolExecutor( | ||
label='local_threads_checkpoint', | ||
) | ||
] | ||
) | ||
|
||
|
||
@contextlib.contextmanager | ||
def parsl_configured(run_dir, **kw): | ||
c = fresh_config() | ||
c.run_dir = run_dir | ||
for config_attr, config_val in kw.items(): | ||
setattr(c, config_attr, config_val) | ||
dfk = parsl.load(c) | ||
for ex in dfk.executors.values(): | ||
ex.working_dir = run_dir | ||
yield dfk | ||
|
||
parsl.dfk().cleanup() | ||
|
||
|
||
@python_app(cache=True) | ||
def uuid_app(): | ||
import uuid | ||
raise RuntimeError(str(uuid.uuid4())) | ||
|
||
|
||
@pytest.mark.local | ||
def test_loading_checkpoint(tmpd_cwd): | ||
"""Load memoization table from previous checkpoint | ||
""" | ||
with parsl_configured(tmpd_cwd, checkpoint_mode="task_exit"): | ||
checkpoint_files = [os.path.join(parsl.dfk().run_dir, "checkpoint")] | ||
result = uuid_app().exception() | ||
|
||
with parsl_configured(tmpd_cwd, checkpoint_files=checkpoint_files): | ||
relaunched = uuid_app().exception() | ||
|
||
assert result.args == relaunched.args, "Expected following call to uuid_app to return cached uuid in exception" |