@@ -33,18 +33,18 @@ def debouncer_test() -> None:
3333
3434 debounce_period = 2
3535
36- debouncer = Debouncer .create (workflow , debounce_key = "key" )
37- first_handle = debouncer .debounce (debounce_period , first_value )
38- debouncer = Debouncer .create (workflow , debounce_key = "key" )
39- second_handle = debouncer .debounce (debounce_period , second_value )
36+ debouncer = Debouncer .create (workflow )
37+ first_handle = debouncer .debounce ("key" , debounce_period , first_value )
38+ debouncer = Debouncer .create (workflow )
39+ second_handle = debouncer .debounce ("key" , debounce_period , second_value )
4040 assert first_handle .workflow_id == second_handle .workflow_id
4141 assert first_handle .get_result () == second_value
4242 assert second_handle .get_result () == second_value
4343
44- debouncer = Debouncer .create (workflow , debounce_key = "key" )
45- third_handle = debouncer .debounce (debounce_period , third_value )
46- debouncer = Debouncer .create (workflow , debounce_key = "key" )
47- fourth_handle = debouncer .debounce (debounce_period , fourth_value )
44+ debouncer = Debouncer .create (workflow )
45+ third_handle = debouncer .debounce ("key" , debounce_period , third_value )
46+ debouncer = Debouncer .create (workflow )
47+ fourth_handle = debouncer .debounce ("key" , debounce_period , fourth_value )
4848 assert third_handle .workflow_id != first_handle .workflow_id
4949 assert third_handle .workflow_id == fourth_handle .workflow_id
5050 assert third_handle .get_result () == fourth_value
@@ -53,7 +53,7 @@ def debouncer_test() -> None:
5353 # Test SetWorkflowID works
5454 wfid = generate_uuid ()
5555 with SetWorkflowID (wfid ):
56- handle = debouncer .debounce (debounce_period , first_value )
56+ handle = debouncer .debounce ("key" , debounce_period , first_value )
5757 assert handle .workflow_id == wfid
5858 assert handle .get_result () == first_value
5959
@@ -83,19 +83,18 @@ def workflow(x: int) -> int:
8383 # Set a huge period but small timeout, verify workflows start after the timeout
8484 debouncer = Debouncer .create (
8585 workflow ,
86- debounce_key = "key" ,
8786 debounce_timeout_sec = 2 ,
8887 )
8988 long_debounce_period = 10000000
9089
91- first_handle = debouncer .debounce (long_debounce_period , first_value )
92- second_handle = debouncer .debounce (long_debounce_period , second_value )
90+ first_handle = debouncer .debounce ("key" , long_debounce_period , first_value )
91+ second_handle = debouncer .debounce ("key" , long_debounce_period , second_value )
9392 assert first_handle .workflow_id == second_handle .workflow_id
9493 assert first_handle .get_result () == second_value
9594 assert second_handle .get_result () == second_value
9695
97- third_handle = debouncer .debounce (long_debounce_period , third_value )
98- fourth_handle = debouncer .debounce (long_debounce_period , fourth_value )
96+ third_handle = debouncer .debounce ("key" , long_debounce_period , third_value )
97+ fourth_handle = debouncer .debounce ("key" , long_debounce_period , fourth_value )
9998 assert third_handle .workflow_id != first_handle .workflow_id
10099 assert third_handle .workflow_id == fourth_handle .workflow_id
101100 assert third_handle .get_result () == fourth_value
@@ -104,12 +103,11 @@ def workflow(x: int) -> int:
104103 # Submit first with a long period then with a short one, verify workflows start on time
105104 debouncer = Debouncer .create (
106105 workflow ,
107- debounce_key = "key" ,
108106 )
109107 short_debounce_period = 1
110108
111- first_handle = debouncer .debounce (long_debounce_period , first_value )
112- second_handle = debouncer .debounce (short_debounce_period , second_value )
109+ first_handle = debouncer .debounce ("key" , long_debounce_period , first_value )
110+ second_handle = debouncer .debounce ("key" , short_debounce_period , second_value )
113111 assert fourth_handle .workflow_id != first_handle .workflow_id
114112 assert first_handle .workflow_id == second_handle .workflow_id
115113 assert first_handle .get_result () == second_value
@@ -125,14 +123,14 @@ def workflow(x: int) -> int:
125123 first_value , second_value , third_value , fourth_value = 0 , 1 , 2 , 3
126124
127125 # Set a huge period but small timeout, verify workflows start after the timeout
128- debouncer_one = Debouncer .create (workflow , debounce_key = "key_one" )
129- debouncer_two = Debouncer .create (workflow , debounce_key = "key_two" )
126+ debouncer_one = Debouncer .create (workflow )
127+ debouncer_two = Debouncer .create (workflow )
130128 debounce_period = 2
131129
132- first_handle = debouncer_one .debounce (debounce_period , first_value )
133- second_handle = debouncer_one .debounce (debounce_period , second_value )
134- third_handle = debouncer_two .debounce (debounce_period , third_value )
135- fourth_handle = debouncer_two .debounce (debounce_period , fourth_value )
130+ first_handle = debouncer_one .debounce ("key_one" , debounce_period , first_value )
131+ second_handle = debouncer_one .debounce ("key_one" , debounce_period , second_value )
132+ third_handle = debouncer_two .debounce ("key_two" , debounce_period , third_value )
133+ fourth_handle = debouncer_two .debounce ("key_two" , debounce_period , fourth_value )
136134 assert first_handle .workflow_id == second_handle .workflow_id
137135 assert first_handle .workflow_id != third_handle .workflow_id
138136 assert third_handle .workflow_id == fourth_handle .workflow_id
@@ -151,20 +149,20 @@ def workflow(x: int) -> int:
151149 first_value , second_value , third_value , fourth_value = 0 , 1 , 2 , 3
152150 queue = Queue ("test-queue" )
153151
154- debouncer = Debouncer .create (workflow , debounce_key = "key" , queue = queue )
152+ debouncer = Debouncer .create (workflow , queue = queue )
155153 debounce_period_sec = 2
156154
157- first_handle = debouncer .debounce (debounce_period_sec , first_value )
158- second_handle = debouncer .debounce (debounce_period_sec , second_value )
155+ first_handle = debouncer .debounce ("key" , debounce_period_sec , first_value )
156+ second_handle = debouncer .debounce ("key" , debounce_period_sec , second_value )
159157 assert first_handle .workflow_id == second_handle .workflow_id
160158 assert first_handle .get_result () == second_value
161159 assert second_handle .get_result () == second_value
162160 assert second_handle .get_status ().queue_name == queue .name
163161
164162 # Test SetWorkflowTimeout works
165163 with SetWorkflowTimeout (5.0 ):
166- third_handle = debouncer .debounce (debounce_period_sec , third_value )
167- fourth_handle = debouncer .debounce (debounce_period_sec , fourth_value )
164+ third_handle = debouncer .debounce ("key" , debounce_period_sec , third_value )
165+ fourth_handle = debouncer .debounce ("key" , debounce_period_sec , fourth_value )
168166 assert third_handle .workflow_id != first_handle .workflow_id
169167 assert third_handle .workflow_id == fourth_handle .workflow_id
170168 assert third_handle .get_result () == fourth_value
@@ -176,7 +174,7 @@ def workflow(x: int) -> int:
176174 # Test SetWorkflowID works
177175 wfid = str (uuid .uuid4 ())
178176 with SetWorkflowID (wfid ):
179- handle = debouncer .debounce (debounce_period_sec , first_value )
177+ handle = debouncer .debounce ("key" , debounce_period_sec , first_value )
180178 assert handle .workflow_id == wfid
181179 assert handle .get_result () == first_value
182180 assert handle .get_status ().queue_name == queue .name
@@ -187,7 +185,7 @@ def workflow(x: int) -> int:
187185 with SetEnqueueOptions (
188186 priority = 1 , deduplication_id = "test" , app_version = test_version
189187 ):
190- handle = debouncer .debounce (debounce_period_sec , first_value )
188+ handle = debouncer .debounce ("key" , debounce_period_sec , first_value )
191189 assert handle .get_result () == first_value
192190 assert handle .get_status ().queue_name == queue .name
193191 assert handle .get_status ().app_version == test_version
@@ -202,17 +200,25 @@ async def workflow_async(x: int) -> int:
202200
203201 first_value , second_value , third_value , fourth_value = 0 , 1 , 2 , 3
204202
205- debouncer = Debouncer .create_async (workflow_async , debounce_key = "key" )
203+ debouncer = Debouncer .create_async (workflow_async )
206204 debounce_period_sec = 2
207205
208- first_handle = await debouncer .debounce_async (debounce_period_sec , first_value )
209- second_handle = await debouncer .debounce_async (debounce_period_sec , second_value )
206+ first_handle = await debouncer .debounce_async (
207+ "key" , debounce_period_sec , first_value
208+ )
209+ second_handle = await debouncer .debounce_async (
210+ "key" , debounce_period_sec , second_value
211+ )
210212 assert first_handle .workflow_id == second_handle .workflow_id
211213 assert await first_handle .get_result () == second_value
212214 assert await second_handle .get_result () == second_value
213215
214- third_handle = await debouncer .debounce_async (debounce_period_sec , third_value )
215- fourth_handle = await debouncer .debounce_async (debounce_period_sec , fourth_value )
216+ third_handle = await debouncer .debounce_async (
217+ "key" , debounce_period_sec , third_value
218+ )
219+ fourth_handle = await debouncer .debounce_async (
220+ "key" , debounce_period_sec , fourth_value
221+ )
216222 assert third_handle .workflow_id != first_handle .workflow_id
217223 assert third_handle .workflow_id == fourth_handle .workflow_id
218224 assert await third_handle .get_result () == fourth_value
@@ -232,24 +238,24 @@ def workflow(x: int) -> int:
232238 "workflow_name" : workflow .__qualname__ ,
233239 "queue_name" : queue .name ,
234240 }
235- debouncer = DebouncerClient (client , options , debounce_key = "key" )
241+ debouncer = DebouncerClient (client , options )
236242 debounce_period_sec = 2
237243
238244 first_handle : WorkflowHandle [int ] = debouncer .debounce (
239- debounce_period_sec , first_value
245+ "key" , debounce_period_sec , first_value
240246 )
241247 second_handle : WorkflowHandle [int ] = debouncer .debounce (
242- debounce_period_sec , second_value
248+ "key" , debounce_period_sec , second_value
243249 )
244250 assert first_handle .workflow_id == second_handle .workflow_id
245251 assert first_handle .get_result () == second_value
246252 assert second_handle .get_result () == second_value
247253
248254 third_handle : WorkflowHandle [int ] = debouncer .debounce (
249- debounce_period_sec , third_value
255+ "key" , debounce_period_sec , third_value
250256 )
251257 fourth_handle : WorkflowHandle [int ] = debouncer .debounce (
252- debounce_period_sec , fourth_value
258+ "key" , debounce_period_sec , fourth_value
253259 )
254260 assert third_handle .workflow_id != first_handle .workflow_id
255261 assert third_handle .workflow_id == fourth_handle .workflow_id
@@ -258,7 +264,9 @@ def workflow(x: int) -> int:
258264
259265 wfid = str (uuid .uuid4 ())
260266 options ["workflow_id" ] = wfid
261- handle : WorkflowHandle [int ] = debouncer .debounce (debounce_period_sec , first_value )
267+ handle : WorkflowHandle [int ] = debouncer .debounce (
268+ "key" , debounce_period_sec , first_value
269+ )
262270 assert handle .workflow_id == wfid
263271 assert handle .get_result () == first_value
264272
@@ -277,24 +285,24 @@ async def workflow_async(x: int) -> int:
277285 "workflow_name" : workflow_async .__qualname__ ,
278286 "queue_name" : queue .name ,
279287 }
280- debouncer = DebouncerClient (client , options , debounce_key = "key" )
288+ debouncer = DebouncerClient (client , options )
281289 debounce_period_sec = 2
282290
283291 first_handle : WorkflowHandleAsync [int ] = await debouncer .debounce_async (
284- debounce_period_sec , first_value
292+ "key" , debounce_period_sec , first_value
285293 )
286294 second_handle : WorkflowHandleAsync [int ] = await debouncer .debounce_async (
287- debounce_period_sec , second_value
295+ "key" , debounce_period_sec , second_value
288296 )
289297 assert first_handle .workflow_id == second_handle .workflow_id
290298 assert await first_handle .get_result () == second_value
291299 assert await second_handle .get_result () == second_value
292300
293301 third_handle : WorkflowHandleAsync [int ] = await debouncer .debounce_async (
294- debounce_period_sec , third_value
302+ "key" , debounce_period_sec , third_value
295303 )
296304 fourth_handle : WorkflowHandleAsync [int ] = await debouncer .debounce_async (
297- debounce_period_sec , fourth_value
305+ "key" , debounce_period_sec , fourth_value
298306 )
299307 assert third_handle .workflow_id != first_handle .workflow_id
300308 assert third_handle .workflow_id == fourth_handle .workflow_id
@@ -304,7 +312,7 @@ async def workflow_async(x: int) -> int:
304312 wfid = str (uuid .uuid4 ())
305313 options ["workflow_id" ] = wfid
306314 handle : WorkflowHandleAsync [int ] = await debouncer .debounce_async (
307- debounce_period_sec , first_value
315+ "key" , debounce_period_sec , first_value
308316 )
309317 assert handle .workflow_id == wfid
310318 assert await handle .get_result () == first_value
0 commit comments