Skip to content

Commit d5d6236

Browse files
authored
Merge pull request #390 from djarecka/enh/faster_checksum_states
checksum_states improvements
2 parents 6bf13d6 + a4726a2 commit d5d6236

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

pydra/engine/core.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,16 @@ def checksum_states(self, state_index=None):
274274
key.split(".")[1],
275275
getattr(inputs_copy, key.split(".")[1])[ind],
276276
)
277+
# setting files_hash again in case it was cleaned by setting specific element
278+
# that might be important for outer splitter of input variable with big files
279+
# the file can be changed with every single index even if there are only two files
280+
inputs_copy.files_hash = self.inputs.files_hash
277281
input_hash = inputs_copy.hash
282+
# updating self.inputs.files_hash, so big files hashes
283+
# doesn't have to be recompute for the next element
284+
for key, val in inputs_copy.files_hash.items():
285+
if val:
286+
self.inputs.files_hash[key].update(val)
278287
if is_workflow(self):
279288
con_hash = hash_function(self._connections)
280289
hash_list = [input_hash, con_hash]

pydra/engine/tests/test_singularity.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
shutil.which("singularity") is None, reason="no singularity available"
1818
)
1919

20+
need_slurm = pytest.mark.skipif(
21+
not bool(shutil.which("sbatch")), reason="no singularity available"
22+
)
23+
2024

2125
@need_singularity
2226
def test_singularity_1_nosubm(tmpdir):
@@ -255,6 +259,26 @@ def test_singularity_st_3(plugin, tmpdir):
255259
assert "Ubuntu" in res[3].output.stdout
256260

257261

262+
@need_singularity
263+
@need_slurm
264+
@pytest.mark.xfail(
265+
reason="slurm can complain if the number of submitted jobs exceeds the limit"
266+
)
267+
@pytest.mark.parametrize("n", [10, 50, 100])
268+
def test_singularity_st_4(tmpdir, n):
269+
""" splitter over args (checking bigger splitters if slurm available)"""
270+
args_n = list(range(n))
271+
image = "library://sylabsed/linux/alpine"
272+
singu = SingularityTask(
273+
name="singu", executable="echo", image=image, cache_dir=tmpdir, args=args_n
274+
).split("args")
275+
assert singu.state.splitter == "singu.args"
276+
res = singu(plugin="slurm")
277+
assert "1" in res[1].output.stdout
278+
assert str(n - 1) in res[-1].output.stdout
279+
assert res[0].output.return_code == res[1].output.return_code == 0
280+
281+
258282
@need_singularity
259283
def test_wf_singularity_1(plugin, tmpdir):
260284
""" a workflow with two connected task

0 commit comments

Comments
 (0)