hatchet-sdk 1.15.3__py3-none-any.whl → 1.16.1__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.
- hatchet_sdk/__init__.py +4 -0
- hatchet_sdk/client.py +2 -0
- hatchet_sdk/clients/admin.py +3 -1
- hatchet_sdk/clients/dispatcher/action_listener.py +13 -13
- hatchet_sdk/clients/event_ts.py +1 -1
- hatchet_sdk/clients/listeners/pooled_listener.py +4 -4
- hatchet_sdk/clients/rest/__init__.py +8 -0
- hatchet_sdk/clients/rest/api/__init__.py +1 -0
- hatchet_sdk/clients/rest/api/cel_api.py +334 -0
- hatchet_sdk/clients/rest/api/task_api.py +12 -10
- hatchet_sdk/clients/rest/models/__init__.py +7 -0
- hatchet_sdk/clients/rest/models/v1_cancelled_tasks.py +87 -0
- hatchet_sdk/clients/rest/models/v1_cel_debug_error_response.py +93 -0
- hatchet_sdk/clients/rest/models/v1_cel_debug_request.py +108 -0
- hatchet_sdk/clients/rest/models/v1_cel_debug_response.py +100 -0
- hatchet_sdk/clients/rest/models/v1_cel_debug_response_status.py +37 -0
- hatchet_sdk/clients/rest/models/v1_cel_debug_success_response.py +102 -0
- hatchet_sdk/clients/rest/models/v1_replayed_tasks.py +87 -0
- hatchet_sdk/clients/rest/tenacity_utils.py +1 -1
- hatchet_sdk/clients/v1/api_client.py +3 -3
- hatchet_sdk/context/context.py +6 -6
- hatchet_sdk/features/cel.py +99 -0
- hatchet_sdk/features/runs.py +21 -1
- hatchet_sdk/hatchet.py +8 -0
- hatchet_sdk/opentelemetry/instrumentor.py +3 -3
- hatchet_sdk/runnables/contextvars.py +4 -0
- hatchet_sdk/runnables/task.py +133 -0
- hatchet_sdk/runnables/workflow.py +218 -11
- hatchet_sdk/worker/action_listener_process.py +11 -11
- hatchet_sdk/worker/runner/runner.py +39 -21
- hatchet_sdk/worker/runner/utils/capture_logs.py +30 -15
- hatchet_sdk/worker/worker.py +11 -14
- {hatchet_sdk-1.15.3.dist-info → hatchet_sdk-1.16.1.dist-info}/METADATA +1 -1
- {hatchet_sdk-1.15.3.dist-info → hatchet_sdk-1.16.1.dist-info}/RECORD +36 -27
- {hatchet_sdk-1.15.3.dist-info → hatchet_sdk-1.16.1.dist-info}/WHEEL +0 -0
- {hatchet_sdk-1.15.3.dist-info → hatchet_sdk-1.16.1.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
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
|
|
23
|
+
from typing_extensions import Annotated, Self
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class V1CancelledTasks(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
V1CancelledTasks
|
|
29
|
+
""" # noqa: E501
|
|
30
|
+
|
|
31
|
+
ids: Optional[
|
|
32
|
+
List[Annotated[str, Field(min_length=36, strict=True, max_length=36)]]
|
|
33
|
+
] = Field(
|
|
34
|
+
default=None, description="The list of task external ids that were cancelled"
|
|
35
|
+
)
|
|
36
|
+
__properties: ClassVar[List[str]] = ["ids"]
|
|
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 V1CancelledTasks 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
|
+
return _dict
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
79
|
+
"""Create an instance of V1CancelledTasks from a dict"""
|
|
80
|
+
if obj is None:
|
|
81
|
+
return None
|
|
82
|
+
|
|
83
|
+
if not isinstance(obj, dict):
|
|
84
|
+
return cls.model_validate(obj)
|
|
85
|
+
|
|
86
|
+
_obj = cls.model_validate({"ids": obj.get("ids")})
|
|
87
|
+
return _obj
|
|
@@ -0,0 +1,93 @@
|
|
|
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 V1CELDebugErrorResponse(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
V1CELDebugErrorResponse
|
|
29
|
+
""" # noqa: E501
|
|
30
|
+
|
|
31
|
+
status: StrictStr
|
|
32
|
+
error: StrictStr = Field(description="The error message if the evaluation failed")
|
|
33
|
+
__properties: ClassVar[List[str]] = ["status", "error"]
|
|
34
|
+
|
|
35
|
+
@field_validator("status")
|
|
36
|
+
def status_validate_enum(cls, value):
|
|
37
|
+
"""Validates the enum"""
|
|
38
|
+
if value not in set(["ERROR"]):
|
|
39
|
+
raise ValueError("must be one of enum values ('ERROR')")
|
|
40
|
+
return value
|
|
41
|
+
|
|
42
|
+
model_config = ConfigDict(
|
|
43
|
+
populate_by_name=True,
|
|
44
|
+
validate_assignment=True,
|
|
45
|
+
protected_namespaces=(),
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
def to_str(self) -> str:
|
|
49
|
+
"""Returns the string representation of the model using alias"""
|
|
50
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
51
|
+
|
|
52
|
+
def to_json(self) -> str:
|
|
53
|
+
"""Returns the JSON representation of the model using alias"""
|
|
54
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
55
|
+
return json.dumps(self.to_dict())
|
|
56
|
+
|
|
57
|
+
@classmethod
|
|
58
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
59
|
+
"""Create an instance of V1CELDebugErrorResponse from a JSON string"""
|
|
60
|
+
return cls.from_dict(json.loads(json_str))
|
|
61
|
+
|
|
62
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
63
|
+
"""Return the dictionary representation of the model using alias.
|
|
64
|
+
|
|
65
|
+
This has the following differences from calling pydantic's
|
|
66
|
+
`self.model_dump(by_alias=True)`:
|
|
67
|
+
|
|
68
|
+
* `None` is only added to the output dict for nullable fields that
|
|
69
|
+
were set at model initialization. Other fields with value `None`
|
|
70
|
+
are ignored.
|
|
71
|
+
"""
|
|
72
|
+
excluded_fields: Set[str] = set([])
|
|
73
|
+
|
|
74
|
+
_dict = self.model_dump(
|
|
75
|
+
by_alias=True,
|
|
76
|
+
exclude=excluded_fields,
|
|
77
|
+
exclude_none=True,
|
|
78
|
+
)
|
|
79
|
+
return _dict
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
83
|
+
"""Create an instance of V1CELDebugErrorResponse from a dict"""
|
|
84
|
+
if obj is None:
|
|
85
|
+
return None
|
|
86
|
+
|
|
87
|
+
if not isinstance(obj, dict):
|
|
88
|
+
return cls.model_validate(obj)
|
|
89
|
+
|
|
90
|
+
_obj = cls.model_validate(
|
|
91
|
+
{"status": obj.get("status"), "error": obj.get("error")}
|
|
92
|
+
)
|
|
93
|
+
return _obj
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
|
23
|
+
from typing_extensions import Self
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class V1CELDebugRequest(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
V1CELDebugRequest
|
|
29
|
+
""" # noqa: E501
|
|
30
|
+
|
|
31
|
+
expression: StrictStr = Field(description="The CEL expression to evaluate")
|
|
32
|
+
input: Dict[str, Any] = Field(
|
|
33
|
+
description="The input, which simulates the workflow run input"
|
|
34
|
+
)
|
|
35
|
+
filter_payload: Optional[Dict[str, Any]] = Field(
|
|
36
|
+
default=None,
|
|
37
|
+
description="The filter payload, which simulates a payload set on a previous-created filter",
|
|
38
|
+
alias="filterPayload",
|
|
39
|
+
)
|
|
40
|
+
additional_metadata: Optional[Dict[str, Any]] = Field(
|
|
41
|
+
default=None,
|
|
42
|
+
description="Additional metadata, which simulates metadata that could be sent with an event or a workflow run",
|
|
43
|
+
alias="additionalMetadata",
|
|
44
|
+
)
|
|
45
|
+
__properties: ClassVar[List[str]] = [
|
|
46
|
+
"expression",
|
|
47
|
+
"input",
|
|
48
|
+
"filterPayload",
|
|
49
|
+
"additionalMetadata",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
model_config = ConfigDict(
|
|
53
|
+
populate_by_name=True,
|
|
54
|
+
validate_assignment=True,
|
|
55
|
+
protected_namespaces=(),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
def to_str(self) -> str:
|
|
59
|
+
"""Returns the string representation of the model using alias"""
|
|
60
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
61
|
+
|
|
62
|
+
def to_json(self) -> str:
|
|
63
|
+
"""Returns the JSON representation of the model using alias"""
|
|
64
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
65
|
+
return json.dumps(self.to_dict())
|
|
66
|
+
|
|
67
|
+
@classmethod
|
|
68
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
69
|
+
"""Create an instance of V1CELDebugRequest from a JSON string"""
|
|
70
|
+
return cls.from_dict(json.loads(json_str))
|
|
71
|
+
|
|
72
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
73
|
+
"""Return the dictionary representation of the model using alias.
|
|
74
|
+
|
|
75
|
+
This has the following differences from calling pydantic's
|
|
76
|
+
`self.model_dump(by_alias=True)`:
|
|
77
|
+
|
|
78
|
+
* `None` is only added to the output dict for nullable fields that
|
|
79
|
+
were set at model initialization. Other fields with value `None`
|
|
80
|
+
are ignored.
|
|
81
|
+
"""
|
|
82
|
+
excluded_fields: Set[str] = set([])
|
|
83
|
+
|
|
84
|
+
_dict = self.model_dump(
|
|
85
|
+
by_alias=True,
|
|
86
|
+
exclude=excluded_fields,
|
|
87
|
+
exclude_none=True,
|
|
88
|
+
)
|
|
89
|
+
return _dict
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
93
|
+
"""Create an instance of V1CELDebugRequest from a dict"""
|
|
94
|
+
if obj is None:
|
|
95
|
+
return None
|
|
96
|
+
|
|
97
|
+
if not isinstance(obj, dict):
|
|
98
|
+
return cls.model_validate(obj)
|
|
99
|
+
|
|
100
|
+
_obj = cls.model_validate(
|
|
101
|
+
{
|
|
102
|
+
"expression": obj.get("expression"),
|
|
103
|
+
"input": obj.get("input"),
|
|
104
|
+
"filterPayload": obj.get("filterPayload"),
|
|
105
|
+
"additionalMetadata": obj.get("additionalMetadata"),
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
return _obj
|
|
@@ -0,0 +1,100 @@
|
|
|
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, StrictBool, StrictStr
|
|
23
|
+
from typing_extensions import Self
|
|
24
|
+
|
|
25
|
+
from hatchet_sdk.clients.rest.models.v1_cel_debug_response_status import (
|
|
26
|
+
V1CELDebugResponseStatus,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class V1CELDebugResponse(BaseModel):
|
|
31
|
+
"""
|
|
32
|
+
V1CELDebugResponse
|
|
33
|
+
""" # noqa: E501
|
|
34
|
+
|
|
35
|
+
status: V1CELDebugResponseStatus
|
|
36
|
+
output: Optional[StrictBool] = Field(
|
|
37
|
+
default=None,
|
|
38
|
+
description="The result of the CEL expression evaluation, if successful",
|
|
39
|
+
)
|
|
40
|
+
error: Optional[StrictStr] = Field(
|
|
41
|
+
default=None, description="The error message if the evaluation failed"
|
|
42
|
+
)
|
|
43
|
+
__properties: ClassVar[List[str]] = ["status", "output", "error"]
|
|
44
|
+
|
|
45
|
+
model_config = ConfigDict(
|
|
46
|
+
populate_by_name=True,
|
|
47
|
+
validate_assignment=True,
|
|
48
|
+
protected_namespaces=(),
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
def to_str(self) -> str:
|
|
52
|
+
"""Returns the string representation of the model using alias"""
|
|
53
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
54
|
+
|
|
55
|
+
def to_json(self) -> str:
|
|
56
|
+
"""Returns the JSON representation of the model using alias"""
|
|
57
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
58
|
+
return json.dumps(self.to_dict())
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
62
|
+
"""Create an instance of V1CELDebugResponse from a JSON string"""
|
|
63
|
+
return cls.from_dict(json.loads(json_str))
|
|
64
|
+
|
|
65
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
66
|
+
"""Return the dictionary representation of the model using alias.
|
|
67
|
+
|
|
68
|
+
This has the following differences from calling pydantic's
|
|
69
|
+
`self.model_dump(by_alias=True)`:
|
|
70
|
+
|
|
71
|
+
* `None` is only added to the output dict for nullable fields that
|
|
72
|
+
were set at model initialization. Other fields with value `None`
|
|
73
|
+
are ignored.
|
|
74
|
+
"""
|
|
75
|
+
excluded_fields: Set[str] = set([])
|
|
76
|
+
|
|
77
|
+
_dict = self.model_dump(
|
|
78
|
+
by_alias=True,
|
|
79
|
+
exclude=excluded_fields,
|
|
80
|
+
exclude_none=True,
|
|
81
|
+
)
|
|
82
|
+
return _dict
|
|
83
|
+
|
|
84
|
+
@classmethod
|
|
85
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
86
|
+
"""Create an instance of V1CELDebugResponse 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
|
+
"status": obj.get("status"),
|
|
96
|
+
"output": obj.get("output"),
|
|
97
|
+
"error": obj.get("error"),
|
|
98
|
+
}
|
|
99
|
+
)
|
|
100
|
+
return _obj
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
from enum import Enum
|
|
19
|
+
|
|
20
|
+
from typing_extensions import Self
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class V1CELDebugResponseStatus(str, Enum):
|
|
24
|
+
"""
|
|
25
|
+
The status of the CEL evaluation
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
"""
|
|
29
|
+
allowed enum values
|
|
30
|
+
"""
|
|
31
|
+
SUCCESS = "SUCCESS"
|
|
32
|
+
ERROR = "ERROR"
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
def from_json(cls, json_str: str) -> Self:
|
|
36
|
+
"""Create an instance of V1CELDebugResponseStatus from a JSON string"""
|
|
37
|
+
return cls(json.loads(json_str))
|
|
@@ -0,0 +1,102 @@
|
|
|
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 (
|
|
23
|
+
BaseModel,
|
|
24
|
+
ConfigDict,
|
|
25
|
+
Field,
|
|
26
|
+
StrictBool,
|
|
27
|
+
StrictStr,
|
|
28
|
+
field_validator,
|
|
29
|
+
)
|
|
30
|
+
from typing_extensions import Self
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class V1CELDebugSuccessResponse(BaseModel):
|
|
34
|
+
"""
|
|
35
|
+
V1CELDebugSuccessResponse
|
|
36
|
+
""" # noqa: E501
|
|
37
|
+
|
|
38
|
+
status: StrictStr
|
|
39
|
+
output: StrictBool = Field(
|
|
40
|
+
description="The result of the CEL expression evaluation"
|
|
41
|
+
)
|
|
42
|
+
__properties: ClassVar[List[str]] = ["status", "output"]
|
|
43
|
+
|
|
44
|
+
@field_validator("status")
|
|
45
|
+
def status_validate_enum(cls, value):
|
|
46
|
+
"""Validates the enum"""
|
|
47
|
+
if value not in set(["SUCCESS"]):
|
|
48
|
+
raise ValueError("must be one of enum values ('SUCCESS')")
|
|
49
|
+
return value
|
|
50
|
+
|
|
51
|
+
model_config = ConfigDict(
|
|
52
|
+
populate_by_name=True,
|
|
53
|
+
validate_assignment=True,
|
|
54
|
+
protected_namespaces=(),
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
def to_str(self) -> str:
|
|
58
|
+
"""Returns the string representation of the model using alias"""
|
|
59
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
60
|
+
|
|
61
|
+
def to_json(self) -> str:
|
|
62
|
+
"""Returns the JSON representation of the model using alias"""
|
|
63
|
+
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
|
|
64
|
+
return json.dumps(self.to_dict())
|
|
65
|
+
|
|
66
|
+
@classmethod
|
|
67
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
68
|
+
"""Create an instance of V1CELDebugSuccessResponse from a JSON string"""
|
|
69
|
+
return cls.from_dict(json.loads(json_str))
|
|
70
|
+
|
|
71
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
72
|
+
"""Return the dictionary representation of the model using alias.
|
|
73
|
+
|
|
74
|
+
This has the following differences from calling pydantic's
|
|
75
|
+
`self.model_dump(by_alias=True)`:
|
|
76
|
+
|
|
77
|
+
* `None` is only added to the output dict for nullable fields that
|
|
78
|
+
were set at model initialization. Other fields with value `None`
|
|
79
|
+
are ignored.
|
|
80
|
+
"""
|
|
81
|
+
excluded_fields: Set[str] = set([])
|
|
82
|
+
|
|
83
|
+
_dict = self.model_dump(
|
|
84
|
+
by_alias=True,
|
|
85
|
+
exclude=excluded_fields,
|
|
86
|
+
exclude_none=True,
|
|
87
|
+
)
|
|
88
|
+
return _dict
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
92
|
+
"""Create an instance of V1CELDebugSuccessResponse from a dict"""
|
|
93
|
+
if obj is None:
|
|
94
|
+
return None
|
|
95
|
+
|
|
96
|
+
if not isinstance(obj, dict):
|
|
97
|
+
return cls.model_validate(obj)
|
|
98
|
+
|
|
99
|
+
_obj = cls.model_validate(
|
|
100
|
+
{"status": obj.get("status"), "output": obj.get("output")}
|
|
101
|
+
)
|
|
102
|
+
return _obj
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
|
23
|
+
from typing_extensions import Annotated, Self
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class V1ReplayedTasks(BaseModel):
|
|
27
|
+
"""
|
|
28
|
+
V1ReplayedTasks
|
|
29
|
+
""" # noqa: E501
|
|
30
|
+
|
|
31
|
+
ids: Optional[
|
|
32
|
+
List[Annotated[str, Field(min_length=36, strict=True, max_length=36)]]
|
|
33
|
+
] = Field(
|
|
34
|
+
default=None, description="The list of task external ids that were replayed"
|
|
35
|
+
)
|
|
36
|
+
__properties: ClassVar[List[str]] = ["ids"]
|
|
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 V1ReplayedTasks 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
|
+
return _dict
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
79
|
+
"""Create an instance of V1ReplayedTasks from a dict"""
|
|
80
|
+
if obj is None:
|
|
81
|
+
return None
|
|
82
|
+
|
|
83
|
+
if not isinstance(obj, dict):
|
|
84
|
+
return cls.model_validate(obj)
|
|
85
|
+
|
|
86
|
+
_obj = cls.model_validate({"ids": obj.get("ids")})
|
|
87
|
+
return _obj
|
|
@@ -23,7 +23,7 @@ def tenacity_retry(func: Callable[P, R]) -> Callable[P, R]:
|
|
|
23
23
|
def tenacity_alert_retry(retry_state: tenacity.RetryCallState) -> None:
|
|
24
24
|
"""Called between tenacity retries."""
|
|
25
25
|
logger.debug(
|
|
26
|
-
f"
|
|
26
|
+
f"retrying {retry_state.fn}: attempt "
|
|
27
27
|
f"{retry_state.attempt_number} ended with: {retry_state.outcome}",
|
|
28
28
|
)
|
|
29
29
|
|
|
@@ -5,7 +5,7 @@ import tenacity
|
|
|
5
5
|
|
|
6
6
|
from hatchet_sdk.clients.rest.api_client import ApiClient
|
|
7
7
|
from hatchet_sdk.clients.rest.configuration import Configuration
|
|
8
|
-
from hatchet_sdk.clients.rest.exceptions import ServiceException
|
|
8
|
+
from hatchet_sdk.clients.rest.exceptions import NotFoundException, ServiceException
|
|
9
9
|
from hatchet_sdk.config import ClientConfig
|
|
10
10
|
from hatchet_sdk.logger import logger
|
|
11
11
|
from hatchet_sdk.utils.typing import JSONSerializableMapping
|
|
@@ -61,10 +61,10 @@ def retry(func: Callable[P, R]) -> Callable[P, R]:
|
|
|
61
61
|
|
|
62
62
|
def _alert_on_retry(retry_state: tenacity.RetryCallState) -> None:
|
|
63
63
|
logger.debug(
|
|
64
|
-
f"
|
|
64
|
+
f"retrying {retry_state.fn}: attempt "
|
|
65
65
|
f"{retry_state.attempt_number} ended with: {retry_state.outcome}",
|
|
66
66
|
)
|
|
67
67
|
|
|
68
68
|
|
|
69
69
|
def _should_retry(ex: BaseException) -> bool:
|
|
70
|
-
return isinstance(ex, ServiceException)
|
|
70
|
+
return isinstance(ex, ServiceException | NotFoundException)
|
hatchet_sdk/context/context.py
CHANGED
|
@@ -236,8 +236,8 @@ class Context:
|
|
|
236
236
|
step_run_id=self.step_run_id,
|
|
237
237
|
index=ix,
|
|
238
238
|
)
|
|
239
|
-
except Exception
|
|
240
|
-
logger.
|
|
239
|
+
except Exception:
|
|
240
|
+
logger.exception("error putting stream event")
|
|
241
241
|
|
|
242
242
|
async def aio_put_stream(self, data: str | bytes) -> None:
|
|
243
243
|
"""
|
|
@@ -262,8 +262,8 @@ class Context:
|
|
|
262
262
|
return self.dispatcher_client.refresh_timeout(
|
|
263
263
|
step_run_id=self.step_run_id, increment_by=increment_by
|
|
264
264
|
)
|
|
265
|
-
except Exception
|
|
266
|
-
logger.
|
|
265
|
+
except Exception:
|
|
266
|
+
logger.exception("error refreshing timeout")
|
|
267
267
|
|
|
268
268
|
@property
|
|
269
269
|
def retry_count(self) -> int:
|
|
@@ -285,7 +285,7 @@ class Context:
|
|
|
285
285
|
return self.retry_count + 1
|
|
286
286
|
|
|
287
287
|
@property
|
|
288
|
-
def additional_metadata(self) -> JSONSerializableMapping
|
|
288
|
+
def additional_metadata(self) -> JSONSerializableMapping:
|
|
289
289
|
"""
|
|
290
290
|
The additional metadata sent with the current task run.
|
|
291
291
|
|
|
@@ -350,7 +350,7 @@ class Context:
|
|
|
350
350
|
|
|
351
351
|
if not errors:
|
|
352
352
|
logger.error(
|
|
353
|
-
"
|
|
353
|
+
"no step run errors found. `context.task_run_errors` is intended to be run in an on-failure step, and will only work on engine versions more recent than v0.53.10"
|
|
354
354
|
)
|
|
355
355
|
|
|
356
356
|
return errors
|