@@ -4757,21 +4757,35 @@ async def test_resubmit_different_task_same_key_many_clients(c, s):
4757
4757
assert await x2 == 2 # kept old run_spec
4758
4758
4759
4759
4760
+ @pytest .mark .parametrize (
4761
+ "before,after,expect_msg" ,
4762
+ [
4763
+ (object (), 123 , True ),
4764
+ (123 , object (), True ),
4765
+ (o := object (), o , False ),
4766
+ ],
4767
+ )
4760
4768
@gen_cluster (client = True , nthreads = [])
4761
- async def test_resubmit_nondeterministic_task_same_deps (c , s ):
4769
+ async def test_resubmit_nondeterministic_task_same_deps (
4770
+ c , s , before , after , expect_msg
4771
+ ):
4762
4772
"""Some run_specs can't be tokenized deterministically. Silently skip comparison on
4763
- the run_spec in those cases. Dependencies must be the same.
4773
+ the run_spec when both lhs and rhs are nondeterministic.
4774
+ Dependencies must be the same.
4764
4775
"""
4765
- o = object ()
4766
- # Round-tripping `o` through two separate cloudpickle.dumps() calls generates two
4767
- # different object instances, which yield different tokens.
4768
- x1 = c .submit (lambda x : x , o , key = "x" )
4769
- x2 = delayed (lambda x : x )(o , dask_key_name = "x" )
4776
+ x1 = c .submit (lambda x : x , before , key = "x" )
4777
+ x2 = delayed (lambda x : x )(after , dask_key_name = "x" )
4770
4778
y = delayed (lambda x : x )(x2 , dask_key_name = "y" )
4771
- fut = c .compute (y )
4772
- await async_poll_for (lambda : "y" in s .tasks , timeout = 5 )
4779
+
4780
+ with captured_logger ("distributed.scheduler" , level = logging .WARNING ) as log :
4781
+ fut = c .compute (y )
4782
+ await async_poll_for (lambda : "y" in s .tasks , timeout = 5 )
4783
+
4784
+ has_msg = "Detected different `run_spec` for key 'x'" in log .getvalue ()
4785
+ assert has_msg == expect_msg
4786
+
4773
4787
async with Worker (s .address ):
4774
- assert type (await fut ) is object
4788
+ assert type (await fut ) is type ( before )
4775
4789
4776
4790
4777
4791
@pytest .mark .parametrize ("add_deps" , [False , True ])
0 commit comments