hatchet-sdk 1.6.2__py3-none-any.whl → 1.6.3__py3-none-any.whl

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.

Potentially problematic release.


This version of hatchet-sdk might be problematic. Click here for more details.

@@ -195,6 +195,15 @@ class BaseWorkflow(Generic[TWorkflowInput]):
195
195
  key: str | None = None,
196
196
  options: TriggerWorkflowOptions = TriggerWorkflowOptions(),
197
197
  ) -> WorkflowRunTriggerConfig:
198
+ """
199
+ Create a bulk run item for the workflow. This is intended to be used in conjunction with the various `run_many` methods.
200
+
201
+ :param input: The input data for the workflow.
202
+ :param key: The key for the workflow run. This is used to identify the run in the bulk operation and for deduplication.
203
+ :param options: Additional options for the workflow run.
204
+
205
+ :returns: A `WorkflowRunTriggerConfig` object that can be used to trigger the workflow run, which you then pass into the `run_many` methods.
206
+ """
198
207
  return WorkflowRunTriggerConfig(
199
208
  workflow_name=self.config.name,
200
209
  input=self._serialize_input(input),
@@ -216,8 +225,39 @@ class BaseWorkflow(Generic[TWorkflowInput]):
216
225
 
217
226
  class Workflow(BaseWorkflow[TWorkflowInput]):
218
227
  """
219
- A Hatchet workflow, which allows you to define tasks to be run and perform actions on the workflow, such as
220
- running / spawning children and scheduling future runs.
228
+ A Hatchet workflow, which allows you to define tasks to be run and perform actions on the workflow.
229
+
230
+ Workflows in Hatchet represent coordinated units of work that can be triggered, scheduled, or run on a cron schedule.
231
+ Each workflow can contain multiple tasks that can be arranged in dependencies (DAGs), have customized retry behavior,
232
+ timeouts, concurrency controls, and more.
233
+
234
+ Example:
235
+ ```python
236
+ from pydantic import BaseModel
237
+ from hatchet_sdk import Hatchet
238
+
239
+ class MyInput(BaseModel):
240
+ name: str
241
+
242
+ hatchet = Hatchet()
243
+ workflow = hatchet.workflow("my-workflow", input_type=MyInput)
244
+
245
+ @workflow.task()
246
+ def greet(input, ctx):
247
+ return f"Hello, {input.name}!"
248
+
249
+ # Run the workflow
250
+ result = workflow.run(MyInput(name="World"))
251
+ ```
252
+
253
+ Workflows support various execution patterns including:
254
+ - One-time execution with `run()` or `aio_run()`
255
+ - Scheduled execution with `schedule()`
256
+ - Cron-based recurring execution with `create_cron()`
257
+ - Bulk operations with `run_many()`
258
+
259
+ Tasks within workflows can be defined with `@workflow.task()` or `@workflow.durable_task()` decorators
260
+ and can be arranged into complex dependency patterns.
221
261
  """
222
262
 
223
263
  def run_no_wait(
@@ -225,6 +265,15 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
225
265
  input: TWorkflowInput = cast(TWorkflowInput, EmptyModel()),
226
266
  options: TriggerWorkflowOptions = TriggerWorkflowOptions(),
227
267
  ) -> WorkflowRunRef:
268
+ """
269
+ Synchronously trigger a workflow run without waiting for it to complete.
270
+ This method is useful for starting a workflow run and immediately returning a reference to the run without blocking while the workflow runs.
271
+
272
+ :param input: The input data for the workflow.
273
+ :param options: Additional options for workflow execution.
274
+
275
+ :returns: A `WorkflowRunRef` object representing the reference to the workflow run.
276
+ """
228
277
  return self.client._client.admin.run_workflow(
229
278
  workflow_name=self.config.name,
230
279
  input=self._serialize_input(input),
@@ -236,6 +285,17 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
236
285
  input: TWorkflowInput = cast(TWorkflowInput, EmptyModel()),
237
286
  options: TriggerWorkflowOptions = TriggerWorkflowOptions(),
238
287
  ) -> dict[str, Any]:
288
+ """
289
+ Run the workflow synchronously and wait for it to complete.
290
+
291
+ This method triggers a workflow run, blocks until completion, and returns the final result.
292
+
293
+ :param input: The input data for the workflow, must match the workflow's input type.
294
+ :param options: Additional options for workflow execution like metadata and parent workflow ID.
295
+
296
+ :returns: The result of the workflow execution as a dictionary.
297
+ """
298
+
239
299
  ref = self.client._client.admin.run_workflow(
240
300
  workflow_name=self.config.name,
241
301
  input=self._serialize_input(input),
@@ -249,6 +309,16 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
249
309
  input: TWorkflowInput = cast(TWorkflowInput, EmptyModel()),
250
310
  options: TriggerWorkflowOptions = TriggerWorkflowOptions(),
251
311
  ) -> WorkflowRunRef:
312
+ """
313
+ Asynchronously trigger a workflow run without waiting for it to complete.
314
+ This method is useful for starting a workflow run and immediately returning a reference to the run without blocking while the workflow runs.
315
+
316
+ :param input: The input data for the workflow.
317
+ :param options: Additional options for workflow execution.
318
+
319
+ :returns: A `WorkflowRunRef` object representing the reference to the workflow run.
320
+ """
321
+
252
322
  return await self.client._client.admin.aio_run_workflow(
253
323
  workflow_name=self.config.name,
254
324
  input=self._serialize_input(input),
@@ -260,6 +330,16 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
260
330
  input: TWorkflowInput = cast(TWorkflowInput, EmptyModel()),
261
331
  options: TriggerWorkflowOptions = TriggerWorkflowOptions(),
262
332
  ) -> dict[str, Any]:
333
+ """
334
+ Run the workflow asynchronously and wait for it to complete.
335
+
336
+ This method triggers a workflow run, blocks until completion, and returns the final result.
337
+
338
+ :param input: The input data for the workflow, must match the workflow's input type.
339
+ :param options: Additional options for workflow execution like metadata and parent workflow ID.
340
+
341
+ :returns: The result of the workflow execution as a dictionary.
342
+ """
263
343
  ref = await self.client._client.admin.aio_run_workflow(
264
344
  workflow_name=self.config.name,
265
345
  input=self._serialize_input(input),
@@ -272,6 +352,13 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
272
352
  self,
273
353
  workflows: list[WorkflowRunTriggerConfig],
274
354
  ) -> list[dict[str, Any]]:
355
+ """
356
+ Run a workflow in bulk and wait for all runs to complete.
357
+ This method triggers multiple workflow runs, blocks until all of them complete, and returns the final results.
358
+
359
+ :param workflows: A list of `WorkflowRunTriggerConfig` objects, each representing a workflow run to be triggered.
360
+ :returns: A list of results for each workflow run.
361
+ """
275
362
  refs = self.client._client.admin.run_workflows(
276
363
  workflows=workflows,
277
364
  )
@@ -282,6 +369,13 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
282
369
  self,
283
370
  workflows: list[WorkflowRunTriggerConfig],
284
371
  ) -> list[dict[str, Any]]:
372
+ """
373
+ Run a workflow in bulk and wait for all runs to complete.
374
+ This method triggers multiple workflow runs, blocks until all of them complete, and returns the final results.
375
+
376
+ :param workflows: A list of `WorkflowRunTriggerConfig` objects, each representing a workflow run to be triggered.
377
+ :returns: A list of results for each workflow run.
378
+ """
285
379
  refs = await self.client._client.admin.aio_run_workflows(
286
380
  workflows=workflows,
287
381
  )
@@ -292,6 +386,14 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
292
386
  self,
293
387
  workflows: list[WorkflowRunTriggerConfig],
294
388
  ) -> list[WorkflowRunRef]:
389
+ """
390
+ Run a workflow in bulk without waiting for all runs to complete.
391
+
392
+ This method triggers multiple workflow runs and immediately returns a list of references to the runs without blocking while the workflows run.
393
+
394
+ :param workflows: A list of `WorkflowRunTriggerConfig` objects, each representing a workflow run to be triggered.
395
+ :returns: A list of `WorkflowRunRef` objects, each representing a reference to a workflow run.
396
+ """
295
397
  return self.client._client.admin.run_workflows(
296
398
  workflows=workflows,
297
399
  )
@@ -300,6 +402,15 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
300
402
  self,
301
403
  workflows: list[WorkflowRunTriggerConfig],
302
404
  ) -> list[WorkflowRunRef]:
405
+ """
406
+ Run a workflow in bulk without waiting for all runs to complete.
407
+
408
+ This method triggers multiple workflow runs and immediately returns a list of references to the runs without blocking while the workflows run.
409
+
410
+ :param workflows: A list of `WorkflowRunTriggerConfig` objects, each representing a workflow run to be triggered.
411
+
412
+ :returns: A list of `WorkflowRunRef` objects, each representing a reference to a workflow run.
413
+ """
303
414
  return await self.client._client.admin.aio_run_workflows(
304
415
  workflows=workflows,
305
416
  )
@@ -310,6 +421,14 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
310
421
  input: TWorkflowInput = cast(TWorkflowInput, EmptyModel()),
311
422
  options: ScheduleTriggerWorkflowOptions = ScheduleTriggerWorkflowOptions(),
312
423
  ) -> WorkflowVersion:
424
+ """
425
+ Schedule a workflow to run at a specific time.
426
+
427
+ :param run_at: The time at which to schedule the workflow.
428
+ :param input: The input data for the workflow.
429
+ :param options: Additional options for workflow execution.
430
+ :returns: A `WorkflowVersion` object representing the scheduled workflow.
431
+ """
313
432
  return self.client._client.admin.schedule_workflow(
314
433
  name=self.config.name,
315
434
  schedules=cast(list[datetime | timestamp_pb2.Timestamp], [run_at]),
@@ -323,6 +442,14 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
323
442
  input: TWorkflowInput = cast(TWorkflowInput, EmptyModel()),
324
443
  options: ScheduleTriggerWorkflowOptions = ScheduleTriggerWorkflowOptions(),
325
444
  ) -> WorkflowVersion:
445
+ """
446
+ Schedule a workflow to run at a specific time.
447
+
448
+ :param run_at: The time at which to schedule the workflow.
449
+ :param input: The input data for the workflow.
450
+ :param options: Additional options for workflow execution.
451
+ :returns: A `WorkflowVersion` object representing the scheduled workflow.
452
+ """
326
453
  return await self.client._client.admin.aio_schedule_workflow(
327
454
  name=self.config.name,
328
455
  schedules=cast(list[datetime | timestamp_pb2.Timestamp], [run_at]),
@@ -338,6 +465,17 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
338
465
  additional_metadata: JSONSerializableMapping = {},
339
466
  priority: int | None = None,
340
467
  ) -> CronWorkflows:
468
+ """
469
+ Create a cron job for the workflow.
470
+
471
+ :param cron_name: The name of the cron job.
472
+ :param expression: The cron expression that defines the schedule for the cron job.
473
+ :param input: The input data for the workflow.
474
+ :param additional_metadata: Additional metadata for the cron job.
475
+ :param priority: The priority of the cron job. Must be between 1 and 3, inclusive.
476
+
477
+ :returns: A `CronWorkflows` object representing the created cron job.
478
+ """
341
479
  return self.client.cron.create(
342
480
  workflow_name=self.config.name,
343
481
  cron_name=cron_name,
@@ -355,6 +493,17 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
355
493
  additional_metadata: JSONSerializableMapping = {},
356
494
  priority: int | None = None,
357
495
  ) -> CronWorkflows:
496
+ """
497
+ Create a cron job for the workflow.
498
+
499
+ :param cron_name: The name of the cron job.
500
+ :param expression: The cron expression that defines the schedule for the cron job.
501
+ :param input: The input data for the workflow.
502
+ :param additional_metadata: Additional metadata for the cron job.
503
+ :param priority: The priority of the cron job. Must be between 1 and 3, inclusive.
504
+
505
+ :returns: A `CronWorkflows` object representing the created cron job.
506
+ """
358
507
  return await self.client.cron.aio_create(
359
508
  workflow_name=self.config.name,
360
509
  cron_name=cron_name,
@@ -393,46 +542,35 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
393
542
  cancel_if: list[Condition | OrGroup] = [],
394
543
  ) -> Callable[[Callable[[TWorkflowInput, Context], R]], Task[TWorkflowInput, R]]:
395
544
  """
396
- A decorator to transform a function into a Hatchet task that run as part of a workflow.
545
+ A decorator to transform a function into a Hatchet task that runs as part of a workflow.
397
546
 
398
547
  :param name: The name of the task. If not specified, defaults to the name of the function being wrapped by the `task` decorator.
399
- :type name: str | None
400
548
 
401
- :param timeout: The execution timeout of the task. Defaults to 60 minutes.
402
- :type timeout: datetime.timedelta | str
549
+ :param schedule_timeout: The maximum time to wait for the task to be scheduled. The run will be canceled if the task does not begin within this time.
550
+
551
+ :param execution_timeout: The maximum time to wait for the task to complete. The run will be canceled if the task does not complete within this time.
403
552
 
404
- :param parents: A list of tasks that are parents of the task. Note: Parents must be defined before their children. Defaults to an empty list (no parents).
405
- :type parents: list[Task]
553
+ :param parents: A list of tasks that are parents of the task. Note: Parents must be defined before their children.
406
554
 
407
- :param retries: The number of times to retry the task before failing. Default: `0`
408
- :type retries: int
555
+ :param retries: The number of times to retry the task before failing.
409
556
 
410
- :param rate_limits: A list of rate limit configurations for the task. Defaults to an empty list (no rate limits).
411
- :type rate_limits: list[RateLimit]
557
+ :param rate_limits: A list of rate limit configurations for the task.
412
558
 
413
- :param desired_worker_labels: A dictionary of desired worker labels that determine to which worker the task should be assigned. See documentation and examples on affinity and worker labels for more details. Defaults to an empty dictionary (no desired worker labels).
414
- :type desired_worker_labels: dict[str, DesiredWorkerLabel]
559
+ :param desired_worker_labels: A dictionary of desired worker labels that determine to which worker the task should be assigned. See documentation and examples on affinity and worker labels for more details.
415
560
 
416
- :param backoff_factor: The backoff factor for controlling exponential backoff in retries. Default: `None`
417
- :type backoff_factor: float | None
561
+ :param backoff_factor: The backoff factor for controlling exponential backoff in retries.
418
562
 
419
- :param backoff_max_seconds: The maximum number of seconds to allow retries with exponential backoff to continue. Default: `None`
420
- :type backoff_max_seconds: int | None
563
+ :param backoff_max_seconds: The maximum number of seconds to allow retries with exponential backoff to continue.
421
564
 
422
- :param concurrency: A list of concurrency expressions for the task. Defaults to an empty list (no concurrency).
423
- :type concurrency: list[ConcurrencyExpression]
565
+ :param concurrency: A list of concurrency expressions for the task.
424
566
 
425
- :param wait_for: A list of conditions that must be met before the task can run. Defaults to an empty list (no conditions).
426
- :type wait_for: list[Condition | OrGroup]
567
+ :param wait_for: A list of conditions that must be met before the task can run.
427
568
 
428
- :param skip_if: A list of conditions that, if met, will cause the task to be skipped. Defaults to an empty list (no conditions).
429
- :type skip_if: list[Condition | OrGroup]
569
+ :param skip_if: A list of conditions that, if met, will cause the task to be skipped.
430
570
 
431
- :param cancel_if: A list of conditions that, if met, will cause the task to be canceled. Defaults to an empty list (no conditions).
432
- :type cancel_if: list[Condition | OrGroup]
571
+ :param cancel_if: A list of conditions that, if met, will cause the task to be canceled.
433
572
 
434
573
  :returns: A decorator which creates a `Task` object.
435
- :rtype: Callable[[Callable[[Type[BaseModel], Context], R]], Task[Type[BaseModel], R]]
436
574
  """
437
575
 
438
576
  def inner(
@@ -493,43 +631,32 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
493
631
  See the Hatchet docs for more information on durable execution to decide if this is right for you.
494
632
 
495
633
  :param name: The name of the task. If not specified, defaults to the name of the function being wrapped by the `task` decorator.
496
- :type name: str | None
497
634
 
498
- :param timeout: The execution timeout of the task. Defaults to 60 minutes.
499
- :type timeout: datetime.timedelta | str
635
+ :param schedule_timeout: The maximum time to wait for the task to be scheduled. The run will be canceled if the task does not begin within this time.
500
636
 
501
- :param parents: A list of tasks that are parents of the task. Note: Parents must be defined before their children. Defaults to an empty list (no parents).
502
- :type parents: list[Task]
637
+ :param execution_timeout: The maximum time to wait for the task to complete. The run will be canceled if the task does not complete within this time.
503
638
 
504
- :param retries: The number of times to retry the task before failing. Default: `0`
505
- :type retries: int
639
+ :param parents: A list of tasks that are parents of the task. Note: Parents must be defined before their children.
506
640
 
507
- :param rate_limits: A list of rate limit configurations for the task. Defaults to an empty list (no rate limits).
508
- :type rate_limits: list[RateLimit]
641
+ :param retries: The number of times to retry the task before failing.
509
642
 
510
- :param desired_worker_labels: A dictionary of desired worker labels that determine to which worker the task should be assigned. See documentation and examples on affinity and worker labels for more details. Defaults to an empty dictionary (no desired worker labels).
511
- :type desired_worker_labels: dict[str, DesiredWorkerLabel]
643
+ :param rate_limits: A list of rate limit configurations for the task.
512
644
 
513
- :param backoff_factor: The backoff factor for controlling exponential backoff in retries. Default: `None`
514
- :type backoff_factor: float | None
645
+ :param desired_worker_labels: A dictionary of desired worker labels that determine to which worker the task should be assigned. See documentation and examples on affinity and worker labels for more details.
515
646
 
516
- :param backoff_max_seconds: The maximum number of seconds to allow retries with exponential backoff to continue. Default: `None`
517
- :type backoff_max_seconds: int | None
647
+ :param backoff_factor: The backoff factor for controlling exponential backoff in retries.
518
648
 
519
- :param concurrency: A list of concurrency expressions for the task. Defaults to an empty list (no concurrency).
520
- :type concurrency: list[ConcurrencyExpression]
649
+ :param backoff_max_seconds: The maximum number of seconds to allow retries with exponential backoff to continue.
521
650
 
522
- :param wait_for: A list of conditions that must be met before the task can run. Defaults to an empty list (no conditions).
523
- :type wait_for: list[Condition | OrGroup]
651
+ :param concurrency: A list of concurrency expressions for the task.
524
652
 
525
- :param skip_if: A list of conditions that, if met, will cause the task to be skipped. Defaults to an empty list (no conditions).
526
- :type skip_if: list[Condition | OrGroup]
653
+ :param wait_for: A list of conditions that must be met before the task can run.
527
654
 
528
- :param cancel_if: A list of conditions that, if met, will cause the task to be canceled. Defaults to an empty list (no conditions).
529
- :type cancel_if: list[Condition | OrGroup]
655
+ :param skip_if: A list of conditions that, if met, will cause the task to be skipped.
656
+
657
+ :param cancel_if: A list of conditions that, if met, will cause the task to be canceled.
530
658
 
531
659
  :returns: A decorator which creates a `Task` object.
532
- :rtype: Callable[[Callable[[Type[BaseModel], Context], R]], Task[Type[BaseModel], R]]
533
660
  """
534
661
 
535
662
  def inner(
@@ -579,25 +706,22 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
579
706
  A decorator to transform a function into a Hatchet on-failure task that runs as the last step in a workflow that had at least one task fail.
580
707
 
581
708
  :param name: The name of the on-failure task. If not specified, defaults to the name of the function being wrapped by the `on_failure_task` decorator.
582
- :type name: str | None
583
709
 
584
- :param timeout: The execution timeout of the on-failure task. Defaults to 60 minutes.
585
- :type timeout: datetime.timedelta | str
710
+ :param schedule_timeout: The maximum time to wait for the task to be scheduled. The run will be canceled if the task does not begin within this time.
711
+
712
+ :param execution_timeout: The maximum time to wait for the task to complete. The run will be canceled if the task does not complete within this time.
586
713
 
587
- :param retries: The number of times to retry the on-failure task before failing. Default: `0`
588
- :type retries: int
714
+ :param retries: The number of times to retry the on-failure task before failing.
589
715
 
590
- :param rate_limits: A list of rate limit configurations for the on-failure task. Defaults to an empty list (no rate limits).
591
- :type rate_limits: list[RateLimit]
716
+ :param rate_limits: A list of rate limit configurations for the on-failure task.
592
717
 
593
- :param backoff_factor: The backoff factor for controlling exponential backoff in retries. Default: `None`
594
- :type backoff_factor: float | None
718
+ :param backoff_factor: The backoff factor for controlling exponential backoff in retries.
595
719
 
596
- :param backoff_max_seconds: The maximum number of seconds to allow retries with exponential backoff to continue. Default: `None`
597
- :type backoff_max_seconds: int | None
720
+ :param backoff_max_seconds: The maximum number of seconds to allow retries with exponential backoff to continue.
721
+
722
+ :param concurrency: A list of concurrency expressions for the on-success task.
598
723
 
599
724
  :returns: A decorator which creates a `Task` object.
600
- :rtype: Callable[[Callable[[Type[BaseModel], Context], R]], Task[Type[BaseModel], R]]
601
725
  """
602
726
 
603
727
  def inner(
@@ -642,25 +766,22 @@ class Workflow(BaseWorkflow[TWorkflowInput]):
642
766
  A decorator to transform a function into a Hatchet on-success task that runs as the last step in a workflow that had all upstream tasks succeed.
643
767
 
644
768
  :param name: The name of the on-success task. If not specified, defaults to the name of the function being wrapped by the `on_failure_task` decorator.
645
- :type name: str | None
646
769
 
647
- :param timeout: The execution timeout of the on-success task. Defaults to 60 minutes.
648
- :type timeout: datetime.timedelta | str
770
+ :param schedule_timeout: The maximum time to wait for the task to be scheduled. The run will be canceled if the task does not begin within this time.
649
771
 
650
- :param retries: The number of times to retry the on-success task before failing. Default: `0`
651
- :type retries: int
772
+ :param execution_timeout: The maximum time to wait for the task to complete. The run will be canceled if the task does not complete within this time.
652
773
 
653
- :param rate_limits: A list of rate limit configurations for the on-success task. Defaults to an empty list (no rate limits).
654
- :type rate_limits: list[RateLimit]
774
+ :param retries: The number of times to retry the on-success task before failing
655
775
 
656
- :param backoff_factor: The backoff factor for controlling exponential backoff in retries. Default: `None`
657
- :type backoff_factor: float | None
776
+ :param rate_limits: A list of rate limit configurations for the on-success task.
658
777
 
659
- :param backoff_max_seconds: The maximum number of seconds to allow retries with exponential backoff to continue. Default: `None`
660
- :type backoff_max_seconds: int | None
778
+ :param backoff_factor: The backoff factor for controlling exponential backoff in retries.
661
779
 
662
- :returns: A decorator which creates a `Task` object.
663
- :rtype: Callable[[Callable[[Type[BaseModel], Context], R]], Task[Type[BaseModel], R]]
780
+ :param backoff_max_seconds: The maximum number of seconds to allow retries with exponential backoff to continue.
781
+
782
+ :param concurrency: A list of concurrency expressions for the on-success task.
783
+
784
+ :returns: A decorator which creates a Task object.
664
785
  """
665
786
 
666
787
  def inner(
@@ -20,7 +20,7 @@ class CreateCronTriggerInput(BaseModel):
20
20
  Attributes:
21
21
  expression (str): The cron expression defining the schedule.
22
22
  input (dict): The input data for the cron workflow.
23
- additional_metadata (dict[str, str]): Additional metadata associated with the cron trigger (e.g. {"key1": "value1", "key2": "value2"}).
23
+ additional_metadata (dict[str, str]): Additional metadata associated with the cron trigger.
24
24
  """
25
25
 
26
26
  expression: str = None
@@ -97,7 +97,7 @@ class CronClient:
97
97
  cron_name (str): The name of the cron trigger.
98
98
  expression (str): The cron expression defining the schedule.
99
99
  input (dict): The input data for the cron workflow.
100
- additional_metadata (dict[str, str]): Additional metadata associated with the cron trigger (e.g. {"key1": "value1", "key2": "value2"}).
100
+ additional_metadata (dict[str, str]): Additional metadata associated with the cron trigger.
101
101
 
102
102
  Returns:
103
103
  CronWorkflows: The created cron workflow instance.
@@ -209,7 +209,7 @@ class CronClientAsync:
209
209
  cron_name (str): The name of the cron trigger.
210
210
  expression (str): The cron expression defining the schedule.
211
211
  input (dict): The input data for the cron workflow.
212
- additional_metadata (dict[str, str]): Additional metadata associated with the cron trigger (e.g. {"key1": "value1", "key2": "value2"}).
212
+ additional_metadata (dict[str, str]): Additional metadata associated with the cron trigger.
213
213
 
214
214
  Returns:
215
215
  CronWorkflows: The created cron workflow instance.
@@ -67,7 +67,7 @@ class ScheduledClient:
67
67
  workflow_name (str): The name of the scheduled workflow.
68
68
  trigger_at (datetime.datetime): The datetime when the run should be triggered.
69
69
  input (Dict[str, Any]): The input data for the scheduled workflow.
70
- additional_metadata (Dict[str, str]): Additional metadata associated with the future run as a key-value pair (e.g. {"key1": "value1", "key2": "value2"}).
70
+ additional_metadata (Dict[str, str]): Additional metadata associated with the future run as a key-value pair.
71
71
 
72
72
  Returns:
73
73
  ScheduledWorkflows: The created scheduled workflow instance.
hatchet_sdk/v0/hatchet.py CHANGED
@@ -234,9 +234,9 @@ class Hatchet:
234
234
  Initialize a new Hatchet instance.
235
235
 
236
236
  Args:
237
- debug (bool, optional): Enable debug logging. Defaults to False.
238
- client (Optional[Client], optional): A pre-configured Client instance. Defaults to None.
239
- config (ClientConfig, optional): Configuration for creating a new Client. Defaults to ClientConfig().
237
+ debug (bool, optional): Enable debug logging.
238
+ client (Optional[Client], optional): A pre-configured Client instance.
239
+ config (ClientConfig, optional): Configuration for creating a new Client.
240
240
  """
241
241
  if client is not None:
242
242
  self._client = client
@@ -57,7 +57,6 @@ def create_traceparent() -> str | None:
57
57
  :returns: A W3C-formatted traceparent header value if successful, None if the context
58
58
  injection fails or no active span exists.\n
59
59
  Example: `00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01`
60
- :rtype: str | None:
61
60
  """
62
61
 
63
62
  carrier: dict[str, str] = {}
@@ -75,10 +74,9 @@ def parse_carrier_from_metadata(metadata: dict[str, str] | None) -> Context | No
75
74
 
76
75
  :param metadata: A dictionary containing metadata key-value pairs,
77
76
  potentially including the `traceparent` header. Can be None.
78
- :type metadata: dict[str, str] | None
77
+
79
78
  :returns: The extracted OpenTelemetry Context object if a valid `traceparent`
80
79
  is found in the metadata, otherwise None.
81
- :rtype: Context | None
82
80
 
83
81
  :Example:
84
82
 
@@ -108,13 +106,12 @@ def inject_traceparent_into_metadata(
108
106
  `OTEL_TRACEPARENT_KEY`. If no `traceparent` is provided, it attempts to create one.
109
107
 
110
108
  :param metadata: The metadata dictionary to inject the `traceparent` into.
111
- :type metadata: dict[str, str]
109
+
112
110
  :param traceparent: The `traceparent` string to inject. If None, attempts to use
113
111
  the current span.
114
- :type traceparent: str | None, optional
112
+
115
113
  :returns: A new metadata dictionary containing the original metadata plus
116
114
  the injected `traceparent`, if one was available or could be created.
117
- :rtype: dict[str, str]
118
115
 
119
116
  :Example:
120
117
 
@@ -11,7 +11,7 @@ from enum import Enum
11
11
  from multiprocessing import Queue
12
12
  from multiprocessing.process import BaseProcess
13
13
  from types import FrameType
14
- from typing import Any, AsyncGenerator, Callable, TypeVar
14
+ from typing import Any, AsyncGenerator, Callable, TypeVar, Union
15
15
  from warnings import warn
16
16
 
17
17
  from aiohttp import web
@@ -60,7 +60,7 @@ class HealthCheckResponse(BaseModel):
60
60
  name: str
61
61
  slots: int
62
62
  actions: list[str]
63
- labels: dict[str, str | int]
63
+ labels: dict[str, Union[str, int]]
64
64
  python_version: str
65
65
 
66
66
 
@@ -88,7 +88,7 @@ class Worker:
88
88
  config: ClientConfig,
89
89
  slots: int,
90
90
  durable_slots: int,
91
- labels: dict[str, str | int] = {},
91
+ labels: dict[str, Union[str, int]] = {},
92
92
  debug: bool = False,
93
93
  owned_loop: bool = True,
94
94
  handle_kill: bool = True,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hatchet-sdk
3
- Version: 1.6.2
3
+ Version: 1.6.3
4
4
  Summary:
5
5
  License: MIT
6
6
  Author: Alexander Belanger