dbos 1.14.0a8__tar.gz → 1.14.0a9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. {dbos-1.14.0a8 → dbos-1.14.0a9}/PKG-INFO +1 -1
  2. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_debouncer.py +12 -17
  3. {dbos-1.14.0a8 → dbos-1.14.0a9}/pyproject.toml +1 -1
  4. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_debouncer.py +55 -47
  5. {dbos-1.14.0a8 → dbos-1.14.0a9}/LICENSE +0 -0
  6. {dbos-1.14.0a8 → dbos-1.14.0a9}/README.md +0 -0
  7. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/__init__.py +0 -0
  8. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/__main__.py +0 -0
  9. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_admin_server.py +0 -0
  10. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/env.py +0 -0
  11. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/script.py.mako +0 -0
  12. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/01ce9f07bd10_streaming.py +0 -0
  13. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/04ca4f231047_workflow_queues_executor_id.py +0 -0
  14. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/27ac6900c6ad_add_queue_dedup.py +0 -0
  15. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/471b60d64126_dbos_migrations.py +0 -0
  16. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/50f3227f0b4b_fix_job_queue.py +0 -0
  17. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/5c361fc04708_added_system_tables.py +0 -0
  18. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/66478e1b95e5_consolidate_queues.py +0 -0
  19. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/83f3732ae8e7_workflow_timeout.py +0 -0
  20. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/933e86bdac6a_add_queue_priority.py +0 -0
  21. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/a3b18ad34abe_added_triggers.py +0 -0
  22. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/d76646551a6b_job_queue_limiter.py +0 -0
  23. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/d76646551a6c_workflow_queue.py +0 -0
  24. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/d994145b47b6_consolidate_inputs.py +0 -0
  25. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/eab0cc1d9a14_job_queue.py +0 -0
  26. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_alembic_migrations/versions/f4b9b32ba814_functionname_childid_op_outputs.py +0 -0
  27. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_app_db.py +0 -0
  28. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_classproperty.py +0 -0
  29. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_client.py +0 -0
  30. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_conductor/conductor.py +0 -0
  31. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_conductor/protocol.py +0 -0
  32. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_context.py +0 -0
  33. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_core.py +0 -0
  34. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_croniter.py +0 -0
  35. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_dbos.py +0 -0
  36. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_dbos_config.py +0 -0
  37. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_debug.py +0 -0
  38. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_docker_pg_helper.py +0 -0
  39. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_error.py +0 -0
  40. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_event_loop.py +0 -0
  41. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_fastapi.py +0 -0
  42. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_flask.py +0 -0
  43. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_kafka.py +0 -0
  44. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_kafka_message.py +0 -0
  45. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_logger.py +0 -0
  46. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_migration.py +0 -0
  47. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_outcome.py +0 -0
  48. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_queue.py +0 -0
  49. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_recovery.py +0 -0
  50. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_registrations.py +0 -0
  51. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_roles.py +0 -0
  52. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_scheduler.py +0 -0
  53. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_schemas/__init__.py +0 -0
  54. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_schemas/application_database.py +0 -0
  55. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_schemas/system_database.py +0 -0
  56. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_serialization.py +0 -0
  57. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_sys_db.py +0 -0
  58. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_sys_db_postgres.py +0 -0
  59. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_sys_db_sqlite.py +0 -0
  60. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_templates/dbos-db-starter/README.md +0 -0
  61. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_templates/dbos-db-starter/__package/__init__.py +0 -0
  62. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_templates/dbos-db-starter/__package/main.py.dbos +0 -0
  63. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_templates/dbos-db-starter/__package/schema.py +0 -0
  64. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_templates/dbos-db-starter/alembic.ini +0 -0
  65. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_templates/dbos-db-starter/dbos-config.yaml.dbos +0 -0
  66. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_templates/dbos-db-starter/migrations/env.py.dbos +0 -0
  67. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_templates/dbos-db-starter/migrations/script.py.mako +0 -0
  68. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_templates/dbos-db-starter/migrations/versions/2024_07_31_180642_init.py +0 -0
  69. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_templates/dbos-db-starter/start_postgres_docker.py +0 -0
  70. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_tracer.py +0 -0
  71. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_utils.py +0 -0
  72. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/_workflow_commands.py +0 -0
  73. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/cli/_github_init.py +0 -0
  74. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/cli/_template_init.py +0 -0
  75. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/cli/cli.py +0 -0
  76. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/cli/migration.py +0 -0
  77. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/dbos-config.schema.json +0 -0
  78. {dbos-1.14.0a8 → dbos-1.14.0a9}/dbos/py.typed +0 -0
  79. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/__init__.py +0 -0
  80. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/atexit_no_ctor.py +0 -0
  81. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/atexit_no_launch.py +0 -0
  82. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/classdefs.py +0 -0
  83. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/client_collateral.py +0 -0
  84. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/client_worker.py +0 -0
  85. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/conftest.py +0 -0
  86. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/dupname_classdefs1.py +0 -0
  87. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/dupname_classdefsa.py +0 -0
  88. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/more_classdefs.py +0 -0
  89. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/queuedworkflow.py +0 -0
  90. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_admin_server.py +0 -0
  91. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_async.py +0 -0
  92. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_async_workflow_management.py +0 -0
  93. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_classdecorators.py +0 -0
  94. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_cli.py +0 -0
  95. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_client.py +0 -0
  96. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_concurrency.py +0 -0
  97. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_config.py +0 -0
  98. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_croniter.py +0 -0
  99. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_dbos.py +0 -0
  100. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_debug.py +0 -0
  101. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_docker_secrets.py +0 -0
  102. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_failures.py +0 -0
  103. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_fastapi.py +0 -0
  104. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_fastapi_roles.py +0 -0
  105. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_flask.py +0 -0
  106. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_kafka.py +0 -0
  107. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_outcome.py +0 -0
  108. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_package.py +0 -0
  109. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_queue.py +0 -0
  110. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_scheduler.py +0 -0
  111. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_schema_migration.py +0 -0
  112. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_singleton.py +0 -0
  113. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_spans.py +0 -0
  114. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_sqlalchemy.py +0 -0
  115. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_streaming.py +0 -0
  116. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_workflow_introspection.py +0 -0
  117. {dbos-1.14.0a8 → dbos-1.14.0a9}/tests/test_workflow_management.py +0 -0
  118. {dbos-1.14.0a8 → dbos-1.14.0a9}/version/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dbos
3
- Version: 1.14.0a8
3
+ Version: 1.14.0a9
4
4
  Summary: Ultra-lightweight durable execution in Python
5
5
  Author-Email: "DBOS, Inc." <contact@dbos.dev>
6
6
  License: MIT
@@ -147,7 +147,6 @@ class Debouncer(Generic[P, R]):
147
147
  self,
148
148
  workflow_name: str,
149
149
  *,
150
- debounce_key: str,
151
150
  debounce_timeout_sec: Optional[float] = None,
152
151
  queue: Optional[Queue] = None,
153
152
  ):
@@ -157,13 +156,11 @@ class Debouncer(Generic[P, R]):
157
156
  "queue_name": queue.name if queue else None,
158
157
  "workflow_name": workflow_name,
159
158
  }
160
- self.debounce_key = debounce_key
161
159
 
162
160
  @staticmethod
163
161
  def create(
164
162
  workflow: Callable[P, R],
165
163
  *,
166
- debounce_key: str,
167
164
  debounce_timeout_sec: Optional[float] = None,
168
165
  queue: Optional[Queue] = None,
169
166
  ) -> "Debouncer[P, R]":
@@ -172,7 +169,6 @@ class Debouncer(Generic[P, R]):
172
169
  raise TypeError("Only workflow functions may be debounced, not methods")
173
170
  return Debouncer[P, R](
174
171
  get_dbos_func_name(workflow),
175
- debounce_key=debounce_key,
176
172
  debounce_timeout_sec=debounce_timeout_sec,
177
173
  queue=queue,
178
174
  )
@@ -181,7 +177,6 @@ class Debouncer(Generic[P, R]):
181
177
  def create_async(
182
178
  workflow: Callable[P, Coroutine[Any, Any, R]],
183
179
  *,
184
- debounce_key: str,
185
180
  debounce_timeout_sec: Optional[float] = None,
186
181
  queue: Optional[Queue] = None,
187
182
  ) -> "Debouncer[P, R]":
@@ -190,13 +185,16 @@ class Debouncer(Generic[P, R]):
190
185
  raise TypeError("Only workflow functions may be debounced, not methods")
191
186
  return Debouncer[P, R](
192
187
  get_dbos_func_name(workflow),
193
- debounce_key=debounce_key,
194
188
  debounce_timeout_sec=debounce_timeout_sec,
195
189
  queue=queue,
196
190
  )
197
191
 
198
192
  def debounce(
199
- self, debounce_period_sec: float, *args: P.args, **kwargs: P.kwargs
193
+ self,
194
+ debounce_key: str,
195
+ debounce_period_sec: float,
196
+ *args: P.args,
197
+ **kwargs: P.kwargs,
200
198
  ) -> "WorkflowHandle[R]":
201
199
  from dbos._dbos import DBOS, _get_dbos_instance
202
200
 
@@ -232,9 +230,7 @@ class Debouncer(Generic[P, R]):
232
230
  while True:
233
231
  try:
234
232
  # Attempt to enqueue a debouncer for this workflow.
235
- deduplication_id = (
236
- f"{self.options['workflow_name']}-{self.debounce_key}"
237
- )
233
+ deduplication_id = f"{self.options['workflow_name']}-{debounce_key}"
238
234
  with SetEnqueueOptions(deduplication_id=deduplication_id):
239
235
  with SetWorkflowTimeout(None):
240
236
  internal_queue.enqueue(
@@ -284,6 +280,7 @@ class Debouncer(Generic[P, R]):
284
280
 
285
281
  async def debounce_async(
286
282
  self,
283
+ debounce_key: str,
287
284
  debounce_period_sec: float,
288
285
  *args: P.args,
289
286
  **kwargs: P.kwargs,
@@ -292,7 +289,7 @@ class Debouncer(Generic[P, R]):
292
289
 
293
290
  dbos = _get_dbos_instance()
294
291
  handle = await asyncio.to_thread(
295
- self.debounce, debounce_period_sec, *args, **kwargs
292
+ self.debounce, debounce_key, debounce_period_sec, *args, **kwargs
296
293
  )
297
294
  return WorkflowHandleAsyncPolling(handle.workflow_id, dbos)
298
295
 
@@ -304,7 +301,6 @@ class DebouncerClient:
304
301
  client: DBOSClient,
305
302
  workflow_options: EnqueueOptions,
306
303
  *,
307
- debounce_key: str,
308
304
  debounce_timeout_sec: Optional[float] = None,
309
305
  queue: Optional[Queue] = None,
310
306
  ):
@@ -314,11 +310,10 @@ class DebouncerClient:
314
310
  "queue_name": queue.name if queue else None,
315
311
  "workflow_name": workflow_options["workflow_name"],
316
312
  }
317
- self.debounce_key = debounce_key
318
313
  self.client = client
319
314
 
320
315
  def debounce(
321
- self, debounce_period_sec: float, *args: Any, **kwargs: Any
316
+ self, debounce_key: str, debounce_period_sec: float, *args: Any, **kwargs: Any
322
317
  ) -> "WorkflowHandle[R]":
323
318
 
324
319
  ctxOptions: ContextOptions = {
@@ -337,7 +332,7 @@ class DebouncerClient:
337
332
  try:
338
333
  # Attempt to enqueue a debouncer for this workflow.
339
334
  deduplication_id = (
340
- f"{self.debouncer_options['workflow_name']}-{self.debounce_key}"
335
+ f"{self.debouncer_options['workflow_name']}-{debounce_key}"
341
336
  )
342
337
  debouncer_options: EnqueueOptions = {
343
338
  "workflow_name": DEBOUNCER_WORKFLOW_NAME,
@@ -390,10 +385,10 @@ class DebouncerClient:
390
385
  )
391
386
 
392
387
  async def debounce_async(
393
- self, debounce_period_sec: float, *args: Any, **kwargs: Any
388
+ self, deboucne_key: str, debounce_period_sec: float, *args: Any, **kwargs: Any
394
389
  ) -> "WorkflowHandleAsync[R]":
395
390
  handle: "WorkflowHandle[R]" = await asyncio.to_thread(
396
- self.debounce, debounce_period_sec, *args, **kwargs
391
+ self.debounce, deboucne_key, debounce_period_sec, *args, **kwargs
397
392
  )
398
393
  return WorkflowHandleClientAsyncPolling[R](
399
394
  handle.workflow_id, self.client._sys_db
@@ -27,7 +27,7 @@ dependencies = [
27
27
  ]
28
28
  requires-python = ">=3.9"
29
29
  readme = "README.md"
30
- version = "1.14.0a8"
30
+ version = "1.14.0a9"
31
31
 
32
32
  [project.license]
33
33
  text = "MIT"
@@ -33,18 +33,18 @@ def test_debouncer(dbos: DBOS) -> None:
33
33
 
34
34
  debounce_period = 2
35
35
 
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)
40
40
  assert first_handle.workflow_id == second_handle.workflow_id
41
41
  assert first_handle.get_result() == second_value
42
42
  assert second_handle.get_result() == second_value
43
43
 
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)
48
48
  assert third_handle.workflow_id != first_handle.workflow_id
49
49
  assert third_handle.workflow_id == fourth_handle.workflow_id
50
50
  assert third_handle.get_result() == fourth_value
@@ -53,7 +53,7 @@ def test_debouncer(dbos: DBOS) -> None:
53
53
  # Test SetWorkflowID works
54
54
  wfid = generate_uuid()
55
55
  with SetWorkflowID(wfid):
56
- handle = debouncer.debounce(debounce_period, first_value)
56
+ handle = debouncer.debounce("key", debounce_period, first_value)
57
57
  assert handle.workflow_id == wfid
58
58
  assert handle.get_result() == first_value
59
59
 
@@ -83,19 +83,18 @@ def test_debouncer_timeout(dbos: DBOS) -> None:
83
83
  # Set a huge period but small timeout, verify workflows start after the timeout
84
84
  debouncer = Debouncer.create(
85
85
  workflow,
86
- debounce_key="key",
87
86
  debounce_timeout_sec=2,
88
87
  )
89
88
  long_debounce_period = 10000000
90
89
 
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)
93
92
  assert first_handle.workflow_id == second_handle.workflow_id
94
93
  assert first_handle.get_result() == second_value
95
94
  assert second_handle.get_result() == second_value
96
95
 
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)
99
98
  assert third_handle.workflow_id != first_handle.workflow_id
100
99
  assert third_handle.workflow_id == fourth_handle.workflow_id
101
100
  assert third_handle.get_result() == fourth_value
@@ -104,12 +103,11 @@ def test_debouncer_timeout(dbos: DBOS) -> None:
104
103
  # Submit first with a long period then with a short one, verify workflows start on time
105
104
  debouncer = Debouncer.create(
106
105
  workflow,
107
- debounce_key="key",
108
106
  )
109
107
  short_debounce_period = 1
110
108
 
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)
113
111
  assert fourth_handle.workflow_id != first_handle.workflow_id
114
112
  assert first_handle.workflow_id == second_handle.workflow_id
115
113
  assert first_handle.get_result() == second_value
@@ -125,14 +123,14 @@ def test_multiple_debouncers(dbos: DBOS) -> None:
125
123
  first_value, second_value, third_value, fourth_value = 0, 1, 2, 3
126
124
 
127
125
  # 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)
130
128
  debounce_period = 2
131
129
 
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)
136
134
  assert first_handle.workflow_id == second_handle.workflow_id
137
135
  assert first_handle.workflow_id != third_handle.workflow_id
138
136
  assert third_handle.workflow_id == fourth_handle.workflow_id
@@ -151,11 +149,11 @@ def test_debouncer_queue(dbos: DBOS) -> None:
151
149
  first_value, second_value, third_value, fourth_value = 0, 1, 2, 3
152
150
  queue = Queue("test-queue")
153
151
 
154
- debouncer = Debouncer.create(workflow, debounce_key="key", queue=queue)
152
+ debouncer = Debouncer.create(workflow, queue=queue)
155
153
  debounce_period_sec = 2
156
154
 
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)
159
157
  assert first_handle.workflow_id == second_handle.workflow_id
160
158
  assert first_handle.get_result() == second_value
161
159
  assert second_handle.get_result() == second_value
@@ -163,8 +161,8 @@ def test_debouncer_queue(dbos: DBOS) -> None:
163
161
 
164
162
  # Test SetWorkflowTimeout works
165
163
  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)
168
166
  assert third_handle.workflow_id != first_handle.workflow_id
169
167
  assert third_handle.workflow_id == fourth_handle.workflow_id
170
168
  assert third_handle.get_result() == fourth_value
@@ -176,7 +174,7 @@ def test_debouncer_queue(dbos: DBOS) -> None:
176
174
  # Test SetWorkflowID works
177
175
  wfid = str(uuid.uuid4())
178
176
  with SetWorkflowID(wfid):
179
- handle = debouncer.debounce(debounce_period_sec, first_value)
177
+ handle = debouncer.debounce("key", debounce_period_sec, first_value)
180
178
  assert handle.workflow_id == wfid
181
179
  assert handle.get_result() == first_value
182
180
  assert handle.get_status().queue_name == queue.name
@@ -187,7 +185,7 @@ def test_debouncer_queue(dbos: DBOS) -> None:
187
185
  with SetEnqueueOptions(
188
186
  priority=1, deduplication_id="test", app_version=test_version
189
187
  ):
190
- handle = debouncer.debounce(debounce_period_sec, first_value)
188
+ handle = debouncer.debounce("key", debounce_period_sec, first_value)
191
189
  assert handle.get_result() == first_value
192
190
  assert handle.get_status().queue_name == queue.name
193
191
  assert handle.get_status().app_version == test_version
@@ -202,17 +200,25 @@ async def test_debouncer_async(dbos: DBOS) -> None:
202
200
 
203
201
  first_value, second_value, third_value, fourth_value = 0, 1, 2, 3
204
202
 
205
- debouncer = Debouncer.create_async(workflow_async, debounce_key="key")
203
+ debouncer = Debouncer.create_async(workflow_async)
206
204
  debounce_period_sec = 2
207
205
 
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
+ )
210
212
  assert first_handle.workflow_id == second_handle.workflow_id
211
213
  assert await first_handle.get_result() == second_value
212
214
  assert await second_handle.get_result() == second_value
213
215
 
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
+ )
216
222
  assert third_handle.workflow_id != first_handle.workflow_id
217
223
  assert third_handle.workflow_id == fourth_handle.workflow_id
218
224
  assert await third_handle.get_result() == fourth_value
@@ -232,24 +238,24 @@ def test_debouncer_client(dbos: DBOS, client: DBOSClient) -> None:
232
238
  "workflow_name": workflow.__qualname__,
233
239
  "queue_name": queue.name,
234
240
  }
235
- debouncer = DebouncerClient(client, options, debounce_key="key")
241
+ debouncer = DebouncerClient(client, options)
236
242
  debounce_period_sec = 2
237
243
 
238
244
  first_handle: WorkflowHandle[int] = debouncer.debounce(
239
- debounce_period_sec, first_value
245
+ "key", debounce_period_sec, first_value
240
246
  )
241
247
  second_handle: WorkflowHandle[int] = debouncer.debounce(
242
- debounce_period_sec, second_value
248
+ "key", debounce_period_sec, second_value
243
249
  )
244
250
  assert first_handle.workflow_id == second_handle.workflow_id
245
251
  assert first_handle.get_result() == second_value
246
252
  assert second_handle.get_result() == second_value
247
253
 
248
254
  third_handle: WorkflowHandle[int] = debouncer.debounce(
249
- debounce_period_sec, third_value
255
+ "key", debounce_period_sec, third_value
250
256
  )
251
257
  fourth_handle: WorkflowHandle[int] = debouncer.debounce(
252
- debounce_period_sec, fourth_value
258
+ "key", debounce_period_sec, fourth_value
253
259
  )
254
260
  assert third_handle.workflow_id != first_handle.workflow_id
255
261
  assert third_handle.workflow_id == fourth_handle.workflow_id
@@ -258,7 +264,9 @@ def test_debouncer_client(dbos: DBOS, client: DBOSClient) -> None:
258
264
 
259
265
  wfid = str(uuid.uuid4())
260
266
  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
+ )
262
270
  assert handle.workflow_id == wfid
263
271
  assert handle.get_result() == first_value
264
272
 
@@ -277,24 +285,24 @@ async def test_debouncer_client_async(dbos: DBOS, client: DBOSClient) -> None:
277
285
  "workflow_name": workflow_async.__qualname__,
278
286
  "queue_name": queue.name,
279
287
  }
280
- debouncer = DebouncerClient(client, options, debounce_key="key")
288
+ debouncer = DebouncerClient(client, options)
281
289
  debounce_period_sec = 2
282
290
 
283
291
  first_handle: WorkflowHandleAsync[int] = await debouncer.debounce_async(
284
- debounce_period_sec, first_value
292
+ "key", debounce_period_sec, first_value
285
293
  )
286
294
  second_handle: WorkflowHandleAsync[int] = await debouncer.debounce_async(
287
- debounce_period_sec, second_value
295
+ "key", debounce_period_sec, second_value
288
296
  )
289
297
  assert first_handle.workflow_id == second_handle.workflow_id
290
298
  assert await first_handle.get_result() == second_value
291
299
  assert await second_handle.get_result() == second_value
292
300
 
293
301
  third_handle: WorkflowHandleAsync[int] = await debouncer.debounce_async(
294
- debounce_period_sec, third_value
302
+ "key", debounce_period_sec, third_value
295
303
  )
296
304
  fourth_handle: WorkflowHandleAsync[int] = await debouncer.debounce_async(
297
- debounce_period_sec, fourth_value
305
+ "key", debounce_period_sec, fourth_value
298
306
  )
299
307
  assert third_handle.workflow_id != first_handle.workflow_id
300
308
  assert third_handle.workflow_id == fourth_handle.workflow_id
@@ -304,7 +312,7 @@ async def test_debouncer_client_async(dbos: DBOS, client: DBOSClient) -> None:
304
312
  wfid = str(uuid.uuid4())
305
313
  options["workflow_id"] = wfid
306
314
  handle: WorkflowHandleAsync[int] = await debouncer.debounce_async(
307
- debounce_period_sec, first_value
315
+ "key", debounce_period_sec, first_value
308
316
  )
309
317
  assert handle.workflow_id == wfid
310
318
  assert await handle.get_result() == first_value
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes