File tree Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Expand file tree Collapse file tree 1 file changed +21
-1
lines changed Original file line number Diff line number Diff line change 1
1
from dateutil import parser
2
2
import re
3
3
import subprocess as sp
4
+ import struct
4
5
import time
5
6
import attrs
6
7
import typing as ty
@@ -575,7 +576,7 @@ def test_sge_no_limit_maxthreads(tmpdir):
575
576
assert job_1_endtime > job_2_starttime
576
577
577
578
578
- def test_hash_changes_in_task_inputs (tmp_path ):
579
+ def test_hash_changes_in_task_inputs_file (tmp_path ):
579
580
@mark .task
580
581
def output_dir_as_input (out_dir : Directory ) -> Directory :
581
582
(out_dir .fspath / "new-file.txt" ).touch ()
@@ -586,6 +587,25 @@ def output_dir_as_input(out_dir: Directory) -> Directory:
586
587
task ()
587
588
588
589
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
+
589
609
def test_hash_changes_in_workflow_inputs (tmp_path ):
590
610
@mark .task
591
611
def output_dir_as_output (out_dir : Path ) -> Directory :
You can’t perform that action at this time.
0 commit comments