Skip to content

Commit 1263f5a

Browse files
committed
added test to hit unstable hash check branch
1 parent 15a775d commit 1263f5a

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

pydra/engine/tests/test_submitter.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from dateutil import parser
22
import re
33
import subprocess as sp
4+
import struct
45
import time
56
import attrs
67
import typing as ty
@@ -575,7 +576,7 @@ def test_sge_no_limit_maxthreads(tmpdir):
575576
assert job_1_endtime > job_2_starttime
576577

577578

578-
def test_hash_changes_in_task_inputs(tmp_path):
579+
def test_hash_changes_in_task_inputs_file(tmp_path):
579580
@mark.task
580581
def output_dir_as_input(out_dir: Directory) -> Directory:
581582
(out_dir.fspath / "new-file.txt").touch()
@@ -586,6 +587,25 @@ def output_dir_as_input(out_dir: Directory) -> Directory:
586587
task()
587588

588589

590+
def test_hash_changes_in_task_inputs_unstable(tmp_path):
591+
@attrs.define
592+
class Unstable:
593+
value: int # type: ignore
594+
595+
def __bytes_repr__(self, cache) -> ty.Iterator[bytes]:
596+
"""Bytes repr based on time-stamp -> inherently unstable"""
597+
yield struct.pack("!I", int(time.time()))
598+
599+
@mark.task
600+
def unstable_input(unstable: Unstable) -> int:
601+
time.sleep(1) # Ensure the timestamp changes during the task run
602+
return unstable.value
603+
604+
task = unstable_input(unstable=Unstable(1))
605+
with pytest.raises(RuntimeError, match="Input field hashes have changed"):
606+
task()
607+
608+
589609
def test_hash_changes_in_workflow_inputs(tmp_path):
590610
@mark.task
591611
def output_dir_as_output(out_dir: Path) -> Directory:

0 commit comments

Comments
 (0)