Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 16 additions & 19 deletions cubed/tests/test_executor_features.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import contextlib
import os
import platform
import re
Expand All @@ -21,6 +20,7 @@
from cubed.diagnostics.tqdm import TqdmProgressBar
from cubed.primitive.blockwise import apply_blockwise
from cubed.runtime.create import create_executor
from cubed.storage.backend import backend_storage_name
from cubed.tests.utils import (
ALL_EXECUTORS,
MAIN_EXECUTORS,
Expand Down Expand Up @@ -190,6 +190,10 @@ def func(a):
b.compute(executor=executor, callbacks=[mem_warn])


@pytest.mark.skipif(
backend_storage_name() == "tensorstore",
reason="tensorstore does not support resume",
)
def test_resume(spec, executor):
if executor.name == "beam":
pytest.skip(f"{executor.name} executor does not support resume")
Expand All @@ -207,24 +211,17 @@ def test_resume(spec, executor):
num_created_arrays = 1 # c
assert task_counter.value == num_created_arrays + 4

if not hasattr(c.zarray, "nchunks_initialized"):
# We expect resume to fail if there is no 'nchunks_initialized' property on the Zarr array
cm = pytest.raises(NotImplementedError)
else:
cm = contextlib.nullcontext()

with cm:
# since c has already been computed, when computing d only 4 tasks are run, instead of 8
task_counter = TaskCounter()
d.compute(
executor=executor,
callbacks=[task_counter],
optimize_graph=False,
resume=True,
)
# the create arrays tasks are run again, even though they exist
num_created_arrays = 2 # c, d
assert task_counter.value == num_created_arrays + 4
# since c has already been computed, when computing d only 4 tasks are run, instead of 8
task_counter = TaskCounter()
d.compute(
executor=executor,
callbacks=[task_counter],
optimize_graph=False,
resume=True,
)
# the create arrays tasks are run again, even though they exist
num_created_arrays = 2 # c, d
assert task_counter.value == num_created_arrays + 4


@pytest.mark.parametrize("compute_arrays_in_parallel", [True, False])
Expand Down
Loading