hatchet-sdk 0.40.0a9__py3-none-any.whl → 0.42.0__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.

Files changed (152) hide show
  1. hatchet_sdk/clients/admin.py +129 -59
  2. hatchet_sdk/clients/dispatcher/action_listener.py +25 -2
  3. hatchet_sdk/clients/events.py +91 -52
  4. hatchet_sdk/clients/rest/__init__.py +21 -0
  5. hatchet_sdk/clients/rest/api/api_token_api.py +12 -9
  6. hatchet_sdk/clients/rest/api/default_api.py +24 -18
  7. hatchet_sdk/clients/rest/api/event_api.py +32 -24
  8. hatchet_sdk/clients/rest/api/github_api.py +4 -3
  9. hatchet_sdk/clients/rest/api/log_api.py +4 -3
  10. hatchet_sdk/clients/rest/api/metadata_api.py +12 -9
  11. hatchet_sdk/clients/rest/api/rate_limits_api.py +7 -4
  12. hatchet_sdk/clients/rest/api/slack_api.py +8 -6
  13. hatchet_sdk/clients/rest/api/sns_api.py +12 -9
  14. hatchet_sdk/clients/rest/api/step_run_api.py +28 -21
  15. hatchet_sdk/clients/rest/api/tenant_api.py +67 -49
  16. hatchet_sdk/clients/rest/api/user_api.py +24 -18
  17. hatchet_sdk/clients/rest/api/worker_api.py +12 -9
  18. hatchet_sdk/clients/rest/api/workflow_api.py +3073 -936
  19. hatchet_sdk/clients/rest/api/workflow_run_api.py +669 -21
  20. hatchet_sdk/clients/rest/api_client.py +34 -11
  21. hatchet_sdk/clients/rest/configuration.py +161 -36
  22. hatchet_sdk/clients/rest/models/__init__.py +21 -0
  23. hatchet_sdk/clients/rest/models/api_errors.py +3 -3
  24. hatchet_sdk/clients/rest/models/bulk_create_event_request.py +3 -3
  25. hatchet_sdk/clients/rest/models/bulk_create_event_response.py +3 -3
  26. hatchet_sdk/clients/{cloud_rest/models/managed_worker_create_request_build_config_steps_inner.py → rest/models/create_cron_workflow_trigger_request.py} +18 -14
  27. hatchet_sdk/clients/{cloud_rest/models/github_app_list_installations200_response_rows_inner.py → rest/models/cron_workflows.py} +54 -21
  28. hatchet_sdk/clients/{cloud_rest/models/log_list200_response.py → rest/models/cron_workflows_list.py} +13 -22
  29. hatchet_sdk/clients/rest/models/cron_workflows_order_by_field.py +37 -0
  30. hatchet_sdk/clients/rest/models/event_list.py +3 -3
  31. hatchet_sdk/clients/rest/models/get_step_run_diff_response.py +3 -3
  32. hatchet_sdk/clients/rest/models/job.py +3 -3
  33. hatchet_sdk/clients/rest/models/job_run.py +3 -3
  34. hatchet_sdk/clients/rest/models/list_api_tokens_response.py +3 -3
  35. hatchet_sdk/clients/rest/models/list_pull_requests_response.py +3 -3
  36. hatchet_sdk/clients/rest/models/list_slack_webhooks.py +3 -3
  37. hatchet_sdk/clients/rest/models/list_sns_integrations.py +3 -3
  38. hatchet_sdk/clients/rest/models/log_line_list.py +3 -3
  39. hatchet_sdk/clients/rest/models/rate_limit_list.py +3 -3
  40. hatchet_sdk/clients/rest/models/replay_workflow_runs_response.py +3 -3
  41. hatchet_sdk/clients/{cloud_rest/models/log_list200_response_rows_inner.py → rest/models/schedule_workflow_run_request.py} +12 -12
  42. hatchet_sdk/clients/rest/models/scheduled_run_status.py +42 -0
  43. hatchet_sdk/clients/rest/models/scheduled_workflows.py +153 -0
  44. hatchet_sdk/clients/{cloud_rest/models/managed_worker_list200_response.py → rest/models/scheduled_workflows_list.py} +13 -22
  45. hatchet_sdk/clients/rest/models/scheduled_workflows_order_by_field.py +37 -0
  46. hatchet_sdk/clients/rest/models/step_run_archive_list.py +3 -3
  47. hatchet_sdk/clients/rest/models/step_run_event_list.py +3 -3
  48. hatchet_sdk/clients/rest/models/tenant_alert_email_group_list.py +3 -3
  49. hatchet_sdk/clients/rest/models/tenant_invite_list.py +3 -3
  50. hatchet_sdk/clients/rest/models/tenant_list.py +3 -3
  51. hatchet_sdk/clients/rest/models/tenant_member_list.py +3 -3
  52. hatchet_sdk/clients/rest/models/tenant_queue_metrics.py +16 -0
  53. hatchet_sdk/clients/rest/models/tenant_resource_policy.py +3 -3
  54. hatchet_sdk/clients/rest/models/tenant_step_run_queue_metrics.py +1 -1
  55. hatchet_sdk/clients/rest/models/user_tenant_memberships_list.py +3 -3
  56. hatchet_sdk/clients/rest/models/webhook_worker_list_response.py +3 -3
  57. hatchet_sdk/clients/rest/models/webhook_worker_request_list_response.py +3 -3
  58. hatchet_sdk/clients/rest/models/worker.py +20 -9
  59. hatchet_sdk/clients/rest/models/worker_list.py +3 -3
  60. hatchet_sdk/clients/{cloud_rest/models/tenant_billing_state_get200_response_payment_methods_inner.py → rest/models/worker_runtime_info.py} +23 -19
  61. hatchet_sdk/clients/rest/models/worker_runtime_sdks.py +38 -0
  62. hatchet_sdk/clients/rest/models/workflow.py +9 -9
  63. hatchet_sdk/clients/rest/models/workflow_list.py +3 -3
  64. hatchet_sdk/clients/rest/models/workflow_run.py +3 -3
  65. hatchet_sdk/clients/rest/models/workflow_run_list.py +3 -3
  66. hatchet_sdk/clients/rest/models/workflow_run_shape.py +3 -3
  67. hatchet_sdk/clients/rest/models/workflow_runs_metrics.py +1 -5
  68. hatchet_sdk/clients/rest/models/workflow_triggers.py +6 -6
  69. hatchet_sdk/clients/rest/models/workflow_version.py +3 -3
  70. hatchet_sdk/clients/rest/rest.py +3 -3
  71. hatchet_sdk/clients/rest_client.py +200 -21
  72. hatchet_sdk/contracts/dispatcher_pb2.py +71 -67
  73. hatchet_sdk/contracts/dispatcher_pb2.pyi +31 -2
  74. hatchet_sdk/contracts/events_pb2.pyi +2 -0
  75. hatchet_sdk/contracts/workflows_pb2.py +42 -40
  76. hatchet_sdk/contracts/workflows_pb2.pyi +24 -6
  77. hatchet_sdk/features/cron.py +286 -0
  78. hatchet_sdk/features/scheduled.py +248 -0
  79. hatchet_sdk/hatchet.py +80 -79
  80. hatchet_sdk/loader.py +37 -14
  81. hatchet_sdk/utils/serialization.py +15 -0
  82. hatchet_sdk/utils/tracing.py +67 -0
  83. hatchet_sdk/worker/runner/runner.py +158 -112
  84. hatchet_sdk/worker/worker.py +1 -17
  85. hatchet_sdk/workflow.py +4 -0
  86. {hatchet_sdk-0.40.0a9.dist-info → hatchet_sdk-0.42.0.dist-info}/METADATA +8 -2
  87. {hatchet_sdk-0.40.0a9.dist-info → hatchet_sdk-0.42.0.dist-info}/RECORD +89 -143
  88. {hatchet_sdk-0.40.0a9.dist-info → hatchet_sdk-0.42.0.dist-info}/entry_points.txt +1 -1
  89. hatchet_sdk/clients/cloud_rest/__init__.py +0 -186
  90. hatchet_sdk/clients/cloud_rest/api/__init__.py +0 -14
  91. hatchet_sdk/clients/cloud_rest/api/billing_api.py +0 -819
  92. hatchet_sdk/clients/cloud_rest/api/build_api.py +0 -298
  93. hatchet_sdk/clients/cloud_rest/api/feature_flags_api.py +0 -295
  94. hatchet_sdk/clients/cloud_rest/api/github_api.py +0 -1347
  95. hatchet_sdk/clients/cloud_rest/api/log_api.py +0 -971
  96. hatchet_sdk/clients/cloud_rest/api/managed_worker_api.py +0 -2546
  97. hatchet_sdk/clients/cloud_rest/api/metadata_api.py +0 -265
  98. hatchet_sdk/clients/cloud_rest/api/metrics_api.py +0 -1026
  99. hatchet_sdk/clients/cloud_rest/api/tenant_api.py +0 -301
  100. hatchet_sdk/clients/cloud_rest/api/user_api.py +0 -473
  101. hatchet_sdk/clients/cloud_rest/api/workflow_api.py +0 -369
  102. hatchet_sdk/clients/cloud_rest/api_client.py +0 -727
  103. hatchet_sdk/clients/cloud_rest/api_response.py +0 -22
  104. hatchet_sdk/clients/cloud_rest/configuration.py +0 -488
  105. hatchet_sdk/clients/cloud_rest/exceptions.py +0 -200
  106. hatchet_sdk/clients/cloud_rest/models/__init__.py +0 -157
  107. hatchet_sdk/clients/cloud_rest/models/billing_portal_link_get200_response.py +0 -85
  108. hatchet_sdk/clients/cloud_rest/models/build_get200_response.py +0 -121
  109. hatchet_sdk/clients/cloud_rest/models/github_app_list_branches200_response_inner.py +0 -86
  110. hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response.py +0 -119
  111. hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_pagination.py +0 -95
  112. hatchet_sdk/clients/cloud_rest/models/github_app_list_installations200_response_rows_inner_metadata.py +0 -98
  113. hatchet_sdk/clients/cloud_rest/models/github_app_list_repos200_response_inner.py +0 -86
  114. hatchet_sdk/clients/cloud_rest/models/infra_as_code_create_request.py +0 -107
  115. hatchet_sdk/clients/cloud_rest/models/log_create_request_inner.py +0 -136
  116. hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_event.py +0 -83
  117. hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_fly.py +0 -100
  118. hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_fly_app.py +0 -86
  119. hatchet_sdk/clients/cloud_rest/models/log_create_request_inner_log.py +0 -83
  120. hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request.py +0 -128
  121. hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_build_config.py +0 -121
  122. hatchet_sdk/clients/cloud_rest/models/managed_worker_create_request_runtime_config.py +0 -166
  123. hatchet_sdk/clients/cloud_rest/models/managed_worker_events_list200_response.py +0 -119
  124. hatchet_sdk/clients/cloud_rest/models/managed_worker_events_list200_response_rows_inner.py +0 -117
  125. hatchet_sdk/clients/cloud_rest/models/managed_worker_instances_list200_response.py +0 -119
  126. hatchet_sdk/clients/cloud_rest/models/managed_worker_instances_list200_response_rows_inner.py +0 -113
  127. hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner.py +0 -154
  128. hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_build_config.py +0 -151
  129. hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_build_config_steps_inner.py +0 -109
  130. hatchet_sdk/clients/cloud_rest/models/managed_worker_list200_response_rows_inner_runtime_configs_inner.py +0 -171
  131. hatchet_sdk/clients/cloud_rest/models/managed_worker_update_request.py +0 -131
  132. hatchet_sdk/clients/cloud_rest/models/metadata_get200_response.py +0 -101
  133. hatchet_sdk/clients/cloud_rest/models/metadata_get400_response.py +0 -105
  134. hatchet_sdk/clients/cloud_rest/models/metadata_get400_response_errors_inner.py +0 -102
  135. hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner.py +0 -108
  136. hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner.py +0 -102
  137. hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner_histogram.py +0 -113
  138. hatchet_sdk/clients/cloud_rest/models/metrics_cpu_get200_response_inner_histograms_inner_histogram_buckets_inner.py +0 -93
  139. hatchet_sdk/clients/cloud_rest/models/runtime_config_list_actions200_response.py +0 -83
  140. hatchet_sdk/clients/cloud_rest/models/subscription_upsert200_response.py +0 -114
  141. hatchet_sdk/clients/cloud_rest/models/subscription_upsert_request.py +0 -88
  142. hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response.py +0 -170
  143. hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_coupons_inner.py +0 -137
  144. hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_plans_inner.py +0 -103
  145. hatchet_sdk/clients/cloud_rest/models/tenant_billing_state_get200_response_subscription.py +0 -114
  146. hatchet_sdk/clients/cloud_rest/models/workflow_run_events_get_metrics200_response.py +0 -107
  147. hatchet_sdk/clients/cloud_rest/models/workflow_run_events_get_metrics200_response_results_inner.py +0 -105
  148. hatchet_sdk/clients/cloud_rest/rest.py +0 -182
  149. hatchet_sdk/compute/__init__.py +0 -0
  150. hatchet_sdk/compute/configs.py +0 -34
  151. hatchet_sdk/compute/managed_compute.py +0 -111
  152. {hatchet_sdk-0.40.0a9.dist-info → hatchet_sdk-0.42.0.dist-info}/WHEEL +0 -0
@@ -1,114 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Hatchet API
5
-
6
- The Hatchet API
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
-
17
- import json
18
- import pprint
19
- import re # noqa: F401
20
- from typing import Any, ClassVar, Dict, List, Optional, Set
21
-
22
- from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator
23
- from typing_extensions import Self
24
-
25
-
26
- class TenantBillingStateGet200ResponseSubscription(BaseModel):
27
- """
28
- The subscription associated with this policy.
29
- """ # noqa: E501
30
-
31
- plan: Optional[StrictStr] = Field(
32
- default=None,
33
- description="The plan code associated with the tenant subscription.",
34
- )
35
- period: Optional[StrictStr] = Field(
36
- default=None, description="The period associated with the tenant subscription."
37
- )
38
- status: Optional[StrictStr] = Field(
39
- default=None, description="The status of the tenant subscription."
40
- )
41
- note: Optional[StrictStr] = Field(
42
- default=None, description="A note associated with the tenant subscription."
43
- )
44
- __properties: ClassVar[List[str]] = ["plan", "period", "status", "note"]
45
-
46
- @field_validator("status")
47
- def status_validate_enum(cls, value):
48
- """Validates the enum"""
49
- if value is None:
50
- return value
51
-
52
- if value not in set(["active", "pending", "terminated", "canceled"]):
53
- raise ValueError(
54
- "must be one of enum values ('active', 'pending', 'terminated', 'canceled')"
55
- )
56
- return value
57
-
58
- model_config = ConfigDict(
59
- populate_by_name=True,
60
- validate_assignment=True,
61
- protected_namespaces=(),
62
- )
63
-
64
- def to_str(self) -> str:
65
- """Returns the string representation of the model using alias"""
66
- return pprint.pformat(self.model_dump(by_alias=True))
67
-
68
- def to_json(self) -> str:
69
- """Returns the JSON representation of the model using alias"""
70
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
71
- return json.dumps(self.to_dict())
72
-
73
- @classmethod
74
- def from_json(cls, json_str: str) -> Optional[Self]:
75
- """Create an instance of TenantBillingStateGet200ResponseSubscription from a JSON string"""
76
- return cls.from_dict(json.loads(json_str))
77
-
78
- def to_dict(self) -> Dict[str, Any]:
79
- """Return the dictionary representation of the model using alias.
80
-
81
- This has the following differences from calling pydantic's
82
- `self.model_dump(by_alias=True)`:
83
-
84
- * `None` is only added to the output dict for nullable fields that
85
- were set at model initialization. Other fields with value `None`
86
- are ignored.
87
- """
88
- excluded_fields: Set[str] = set([])
89
-
90
- _dict = self.model_dump(
91
- by_alias=True,
92
- exclude=excluded_fields,
93
- exclude_none=True,
94
- )
95
- return _dict
96
-
97
- @classmethod
98
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
99
- """Create an instance of TenantBillingStateGet200ResponseSubscription from a dict"""
100
- if obj is None:
101
- return None
102
-
103
- if not isinstance(obj, dict):
104
- return cls.model_validate(obj)
105
-
106
- _obj = cls.model_validate(
107
- {
108
- "plan": obj.get("plan"),
109
- "period": obj.get("period"),
110
- "status": obj.get("status"),
111
- "note": obj.get("note"),
112
- }
113
- )
114
- return _obj
@@ -1,107 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Hatchet API
5
-
6
- The Hatchet API
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
-
17
- import json
18
- import pprint
19
- import re # noqa: F401
20
- from typing import Any, ClassVar, Dict, List, Optional, Set
21
-
22
- from pydantic import BaseModel, ConfigDict
23
- from typing_extensions import Self
24
-
25
- from hatchet_sdk.clients.cloud_rest.models.workflow_run_events_get_metrics200_response_results_inner import (
26
- WorkflowRunEventsGetMetrics200ResponseResultsInner,
27
- )
28
-
29
-
30
- class WorkflowRunEventsGetMetrics200Response(BaseModel):
31
- """
32
- WorkflowRunEventsGetMetrics200Response
33
- """ # noqa: E501
34
-
35
- results: Optional[List[WorkflowRunEventsGetMetrics200ResponseResultsInner]] = None
36
- __properties: ClassVar[List[str]] = ["results"]
37
-
38
- model_config = ConfigDict(
39
- populate_by_name=True,
40
- validate_assignment=True,
41
- protected_namespaces=(),
42
- )
43
-
44
- def to_str(self) -> str:
45
- """Returns the string representation of the model using alias"""
46
- return pprint.pformat(self.model_dump(by_alias=True))
47
-
48
- def to_json(self) -> str:
49
- """Returns the JSON representation of the model using alias"""
50
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
51
- return json.dumps(self.to_dict())
52
-
53
- @classmethod
54
- def from_json(cls, json_str: str) -> Optional[Self]:
55
- """Create an instance of WorkflowRunEventsGetMetrics200Response from a JSON string"""
56
- return cls.from_dict(json.loads(json_str))
57
-
58
- def to_dict(self) -> Dict[str, Any]:
59
- """Return the dictionary representation of the model using alias.
60
-
61
- This has the following differences from calling pydantic's
62
- `self.model_dump(by_alias=True)`:
63
-
64
- * `None` is only added to the output dict for nullable fields that
65
- were set at model initialization. Other fields with value `None`
66
- are ignored.
67
- """
68
- excluded_fields: Set[str] = set([])
69
-
70
- _dict = self.model_dump(
71
- by_alias=True,
72
- exclude=excluded_fields,
73
- exclude_none=True,
74
- )
75
- # override the default output from pydantic by calling `to_dict()` of each item in results (list)
76
- _items = []
77
- if self.results:
78
- for _item in self.results:
79
- if _item:
80
- _items.append(_item.to_dict())
81
- _dict["results"] = _items
82
- return _dict
83
-
84
- @classmethod
85
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
- """Create an instance of WorkflowRunEventsGetMetrics200Response from a dict"""
87
- if obj is None:
88
- return None
89
-
90
- if not isinstance(obj, dict):
91
- return cls.model_validate(obj)
92
-
93
- _obj = cls.model_validate(
94
- {
95
- "results": (
96
- [
97
- WorkflowRunEventsGetMetrics200ResponseResultsInner.from_dict(
98
- _item
99
- )
100
- for _item in obj["results"]
101
- ]
102
- if obj.get("results") is not None
103
- else None
104
- )
105
- }
106
- )
107
- return _obj
@@ -1,105 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Hatchet API
5
-
6
- The Hatchet API
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- from __future__ import annotations
16
-
17
- import json
18
- import pprint
19
- import re # noqa: F401
20
- from datetime import datetime
21
- from typing import Any, ClassVar, Dict, List, Optional, Set
22
-
23
- from pydantic import BaseModel, ConfigDict, Field, StrictInt
24
- from typing_extensions import Self
25
-
26
-
27
- class WorkflowRunEventsGetMetrics200ResponseResultsInner(BaseModel):
28
- """
29
- WorkflowRunEventsGetMetrics200ResponseResultsInner
30
- """ # noqa: E501
31
-
32
- time: datetime
33
- pending: StrictInt = Field(alias="PENDING")
34
- running: StrictInt = Field(alias="RUNNING")
35
- succeeded: StrictInt = Field(alias="SUCCEEDED")
36
- failed: StrictInt = Field(alias="FAILED")
37
- queued: StrictInt = Field(alias="QUEUED")
38
- __properties: ClassVar[List[str]] = [
39
- "time",
40
- "PENDING",
41
- "RUNNING",
42
- "SUCCEEDED",
43
- "FAILED",
44
- "QUEUED",
45
- ]
46
-
47
- model_config = ConfigDict(
48
- populate_by_name=True,
49
- validate_assignment=True,
50
- protected_namespaces=(),
51
- )
52
-
53
- def to_str(self) -> str:
54
- """Returns the string representation of the model using alias"""
55
- return pprint.pformat(self.model_dump(by_alias=True))
56
-
57
- def to_json(self) -> str:
58
- """Returns the JSON representation of the model using alias"""
59
- # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
60
- return json.dumps(self.to_dict())
61
-
62
- @classmethod
63
- def from_json(cls, json_str: str) -> Optional[Self]:
64
- """Create an instance of WorkflowRunEventsGetMetrics200ResponseResultsInner from a JSON string"""
65
- return cls.from_dict(json.loads(json_str))
66
-
67
- def to_dict(self) -> Dict[str, Any]:
68
- """Return the dictionary representation of the model using alias.
69
-
70
- This has the following differences from calling pydantic's
71
- `self.model_dump(by_alias=True)`:
72
-
73
- * `None` is only added to the output dict for nullable fields that
74
- were set at model initialization. Other fields with value `None`
75
- are ignored.
76
- """
77
- excluded_fields: Set[str] = set([])
78
-
79
- _dict = self.model_dump(
80
- by_alias=True,
81
- exclude=excluded_fields,
82
- exclude_none=True,
83
- )
84
- return _dict
85
-
86
- @classmethod
87
- def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
88
- """Create an instance of WorkflowRunEventsGetMetrics200ResponseResultsInner from a dict"""
89
- if obj is None:
90
- return None
91
-
92
- if not isinstance(obj, dict):
93
- return cls.model_validate(obj)
94
-
95
- _obj = cls.model_validate(
96
- {
97
- "time": obj.get("time"),
98
- "PENDING": obj.get("PENDING"),
99
- "RUNNING": obj.get("RUNNING"),
100
- "SUCCEEDED": obj.get("SUCCEEDED"),
101
- "FAILED": obj.get("FAILED"),
102
- "QUEUED": obj.get("QUEUED"),
103
- }
104
- )
105
- return _obj
@@ -1,182 +0,0 @@
1
- # coding: utf-8
2
-
3
- """
4
- Hatchet API
5
-
6
- The Hatchet API
7
-
8
- The version of the OpenAPI document: 1.0.0
9
- Generated by OpenAPI Generator (https://openapi-generator.tech)
10
-
11
- Do not edit the class manually.
12
- """ # noqa: E501
13
-
14
-
15
- import io
16
- import json
17
- import re
18
- import ssl
19
- from typing import Optional, Union
20
-
21
- import aiohttp
22
- import aiohttp_retry
23
-
24
- from hatchet_sdk.clients.cloud_rest.exceptions import ApiException, ApiValueError
25
-
26
- RESTResponseType = aiohttp.ClientResponse
27
-
28
- ALLOW_RETRY_METHODS = frozenset({"DELETE", "GET", "HEAD", "OPTIONS", "PUT", "TRACE"})
29
-
30
-
31
- class RESTResponse(io.IOBase):
32
-
33
- def __init__(self, resp) -> None:
34
- self.response = resp
35
- self.status = resp.status
36
- self.reason = resp.reason
37
- self.data = None
38
-
39
- async def read(self):
40
- if self.data is None:
41
- self.data = await self.response.read()
42
- return self.data
43
-
44
- def getheaders(self):
45
- """Returns a CIMultiDictProxy of the response headers."""
46
- return self.response.headers
47
-
48
- def getheader(self, name, default=None):
49
- """Returns a given response header."""
50
- return self.response.headers.get(name, default)
51
-
52
-
53
- class RESTClientObject:
54
-
55
- def __init__(self, configuration) -> None:
56
-
57
- # maxsize is number of requests to host that are allowed in parallel
58
- maxsize = configuration.connection_pool_maxsize
59
-
60
- ssl_context = ssl.create_default_context(cafile=configuration.ssl_ca_cert)
61
- if configuration.cert_file:
62
- ssl_context.load_cert_chain(
63
- configuration.cert_file, keyfile=configuration.key_file
64
- )
65
-
66
- if not configuration.verify_ssl:
67
- ssl_context.check_hostname = False
68
- ssl_context.verify_mode = ssl.CERT_NONE
69
-
70
- connector = aiohttp.TCPConnector(limit=maxsize, ssl=ssl_context)
71
-
72
- self.proxy = configuration.proxy
73
- self.proxy_headers = configuration.proxy_headers
74
-
75
- # https pool manager
76
- self.pool_manager = aiohttp.ClientSession(connector=connector, trust_env=True)
77
-
78
- retries = configuration.retries
79
- self.retry_client: Optional[aiohttp_retry.RetryClient]
80
- if retries is not None:
81
- self.retry_client = aiohttp_retry.RetryClient(
82
- client_session=self.pool_manager,
83
- retry_options=aiohttp_retry.ExponentialRetry(
84
- attempts=retries, factor=0.0, start_timeout=0.0, max_timeout=120.0
85
- ),
86
- )
87
- else:
88
- self.retry_client = None
89
-
90
- async def close(self):
91
- await self.pool_manager.close()
92
- if self.retry_client is not None:
93
- await self.retry_client.close()
94
-
95
- async def request(
96
- self,
97
- method,
98
- url,
99
- headers=None,
100
- body=None,
101
- post_params=None,
102
- _request_timeout=None,
103
- ):
104
- """Execute request
105
-
106
- :param method: http request method
107
- :param url: http request url
108
- :param headers: http request headers
109
- :param body: request json body, for `application/json`
110
- :param post_params: request post parameters,
111
- `application/x-www-form-urlencoded`
112
- and `multipart/form-data`
113
- :param _request_timeout: timeout setting for this request. If one
114
- number provided, it will be total request
115
- timeout. It can also be a pair (tuple) of
116
- (connection, read) timeouts.
117
- """
118
- method = method.upper()
119
- assert method in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"]
120
-
121
- if post_params and body:
122
- raise ApiValueError(
123
- "body parameter cannot be used with post_params parameter."
124
- )
125
-
126
- post_params = post_params or {}
127
- headers = headers or {}
128
- # url already contains the URL query string
129
- timeout = _request_timeout or 5 * 60
130
-
131
- if "Content-Type" not in headers:
132
- headers["Content-Type"] = "application/json"
133
-
134
- args = {"method": method, "url": url, "timeout": timeout, "headers": headers}
135
-
136
- if self.proxy:
137
- args["proxy"] = self.proxy
138
- if self.proxy_headers:
139
- args["proxy_headers"] = self.proxy_headers
140
-
141
- # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
142
- if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]:
143
- if re.search("json", headers["Content-Type"], re.IGNORECASE):
144
- if body is not None:
145
- body = json.dumps(body)
146
- args["data"] = body
147
- elif headers["Content-Type"] == "application/x-www-form-urlencoded":
148
- args["data"] = aiohttp.FormData(post_params)
149
- elif headers["Content-Type"] == "multipart/form-data":
150
- # must del headers['Content-Type'], or the correct
151
- # Content-Type which generated by aiohttp
152
- del headers["Content-Type"]
153
- data = aiohttp.FormData()
154
- for param in post_params:
155
- k, v = param
156
- if isinstance(v, tuple) and len(v) == 3:
157
- data.add_field(k, value=v[1], filename=v[0], content_type=v[2])
158
- else:
159
- data.add_field(k, v)
160
- args["data"] = data
161
-
162
- # Pass a `bytes` parameter directly in the body to support
163
- # other content types than Json when `body` argument is provided
164
- # in serialized form
165
- elif isinstance(body, bytes):
166
- args["data"] = body
167
- else:
168
- # Cannot generate the request from given parameters
169
- msg = """Cannot prepare a request message for provided
170
- arguments. Please check that your arguments match
171
- declared content type."""
172
- raise ApiException(status=0, reason=msg)
173
-
174
- pool_manager: Union[aiohttp.ClientSession, aiohttp_retry.RetryClient]
175
- if self.retry_client is not None and method in ALLOW_RETRY_METHODS:
176
- pool_manager = self.retry_client
177
- else:
178
- pool_manager = self.pool_manager
179
-
180
- r = await pool_manager.request(**args)
181
-
182
- return RESTResponse(r)
File without changes
@@ -1,34 +0,0 @@
1
- import hashlib
2
- from typing import Annotated, Optional
3
-
4
- from pydantic import BaseModel, Field, StrictStr
5
-
6
-
7
- class Compute(BaseModel):
8
- pool: Optional[str] = Field(
9
- default="default",
10
- description="The name of the compute pool to use",
11
- )
12
- num_replicas: Annotated[int, Field(le=1000, strict=True, ge=0)] = Field(
13
- default=1, alias="num_replicas"
14
- )
15
- # TODO: change to ManagedWorkerRegion
16
- regions: Optional[list[str]] = Field(
17
- default=None, description="The regions to deploy the worker to"
18
- )
19
- cpu_kind: StrictStr = Field(
20
- description="The kind of CPU to use for the worker", alias="cpu_kind"
21
- )
22
- cpus: Annotated[int, Field(le=64, strict=True, ge=1)] = Field(
23
- description="The number of CPUs to use for the worker"
24
- )
25
- memory_mb: Annotated[int, Field(le=65536, strict=True, ge=1024)] = Field(
26
- description="The amount of memory in MB to use for the worker",
27
- alias="memory_mb",
28
- )
29
-
30
- def __json__(self):
31
- return self.model_dump_json()
32
-
33
- def hash(self):
34
- return hashlib.sha256(self.__json__().encode()).hexdigest()
@@ -1,111 +0,0 @@
1
- import os
2
- import sys
3
- from typing import Any, Callable, Dict, List
4
-
5
- from hatchet_sdk.client import Client
6
- from hatchet_sdk.clients.cloud_rest.models.infra_as_code_create_request import (
7
- InfraAsCodeCreateRequest,
8
- )
9
- from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request_runtime_config import (
10
- ManagedWorkerCreateRequestRuntimeConfig,
11
- )
12
- from hatchet_sdk.compute.configs import Compute
13
- from hatchet_sdk.logger import logger
14
-
15
- # TODO why is this not generating
16
- # from hatchet_sdk.clients.cloud_rest.models.managed_worker_create_request import ManagedWorkerRegion
17
-
18
-
19
- class ManagedCompute:
20
- def __init__(
21
- self, actions: Dict[str, Callable[..., Any]], client: Client, max_runs: int = 1
22
- ):
23
- self.actions = actions
24
- self.client = client
25
- self.max_runs = max_runs
26
- self.configs = self.get_compute_configs(self.actions)
27
- self.cloud_register_enabled = os.environ.get("HATCHET_CLOUD_REGISTER_ID")
28
-
29
- if len(self.configs) == 0:
30
- logger.debug(
31
- "no compute configs found, skipping cloud registration and running all actions locally."
32
- )
33
- return
34
-
35
- if self.cloud_register_enabled is None:
36
- logger.warning("managed cloud compute plan:")
37
- for compute in self.configs:
38
- logger.warning(f" ----------------------------")
39
- logger.warning(f" actions: {', '.join(compute.actions)}")
40
- logger.warning(f" num replicas: {compute.num_replicas}")
41
- logger.warning(f" cpu kind: {compute.cpu_kind}")
42
- logger.warning(f" cpus: {compute.cpus}")
43
- logger.warning(f" memory mb: {compute.memory_mb}")
44
- logger.warning(f" regions: {compute.regions}")
45
-
46
- logger.warning(
47
- "NOTICE: local mode detected, skipping cloud registration and running all actions locally."
48
- )
49
-
50
- def get_compute_configs(
51
- self, actions: Dict[str, Callable[..., Any]]
52
- ) -> List[ManagedWorkerCreateRequestRuntimeConfig]:
53
- """
54
- Builds a map of compute hashes to compute configs and lists of actions that correspond to each compute hash.
55
- """
56
- map: Dict[str, ManagedWorkerCreateRequestRuntimeConfig] = {}
57
-
58
- try:
59
- for action, func in actions.items():
60
- compute = func._step_compute
61
-
62
- if compute is None:
63
- continue
64
-
65
- key = compute.hash()
66
- if key not in map:
67
- map[key] = ManagedWorkerCreateRequestRuntimeConfig(
68
- actions=[],
69
- num_replicas=compute.num_replicas,
70
- cpu_kind=compute.cpu_kind,
71
- cpus=compute.cpus,
72
- memory_mb=compute.memory_mb,
73
- regions=compute.regions,
74
- slots=self.max_runs,
75
- )
76
- map[key].actions.append(action)
77
-
78
- return list(map.values())
79
- except Exception as e:
80
- logger.error(f"Error getting compute configs: {e}")
81
- return []
82
-
83
- async def cloud_register(self):
84
-
85
- # if the environment variable HATCHET_CLOUD_REGISTER_ID is set, use it and exit
86
- if self.cloud_register_enabled is not None:
87
- logger.info(
88
- f"Registering cloud compute plan with ID: {self.cloud_register_enabled}"
89
- )
90
-
91
- try:
92
- if len(self.configs) == 0:
93
- logger.warning(
94
- "No actions to register, skipping cloud registration."
95
- )
96
- return
97
-
98
- req = InfraAsCodeCreateRequest(runtime_configs=self.configs)
99
-
100
- res = (
101
- await self.client.rest.aio.managed_worker_api.infra_as_code_create(
102
- infra_as_code_request=self.cloud_register_enabled,
103
- infra_as_code_create_request=req,
104
- _request_timeout=10,
105
- )
106
- )
107
-
108
- sys.exit(0)
109
- except Exception as e:
110
- print("ERROR", e)
111
- sys.exit(1)