volcano-sdk-python 0.15.1__py3-none-any.whl → 0.17.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.
- volcano_sdk/_auth_oauth.py +5 -3
- volcano_sdk/_auth_values.py +0 -3
- volcano_sdk/_durable_arguments.py +7 -0
- volcano_sdk/_durable_callback_token.py +224 -0
- volcano_sdk/_durable_engine.py +13 -6
- volcano_sdk/_durable_modules.py +5 -1
- volcano_sdk/_durable_platform_request.py +7 -1
- volcano_sdk/_durable_protocols.py +6 -1
- volcano_sdk/_generated/api/authentication/auth_forgot_password.py +40 -0
- volcano_sdk/_generated/api/authentication/auth_get_password_policy.py +48 -4
- volcano_sdk/_generated/api/authentication/auth_logout.py +110 -7
- volcano_sdk/_generated/api/authentication/auth_refresh.py +32 -0
- volcano_sdk/_generated/api/authentication/auth_reset_password.py +33 -0
- volcano_sdk/_generated/api/authentication/auth_signin.py +33 -0
- volcano_sdk/_generated/api/authentication/auth_signup.py +33 -0
- volcano_sdk/_generated/api/authentication/auth_signup_anonymous.py +50 -10
- volcano_sdk/_generated/api/autofix/get_autofix_run.py +224 -0
- volcano_sdk/_generated/api/autofix/list_autofix_runs.py +294 -0
- volcano_sdk/_generated/api/autofix/start_autofix_run.py +291 -0
- volcano_sdk/_generated/api/durable_functions/fail_durable_callback.py +256 -0
- volcano_sdk/_generated/api/durable_functions/heartbeat_durable_callback.py +248 -0
- volcano_sdk/_generated/api/durable_functions/publish_durable_message.py +12 -4
- volcano_sdk/_generated/api/durable_functions/register_durable_callback.py +276 -0
- volcano_sdk/_generated/api/durable_functions/succeed_durable_callback.py +260 -0
- volcano_sdk/_generated/api/frontends/create_frontend.py +8 -8
- volcano_sdk/_generated/api/functions/invoke_function.py +24 -0
- volcano_sdk/_generated/api/o_auth_authentication/auth_o_auth_exchange.py +33 -0
- volcano_sdk/_generated/api/projects/get_project_health.py +8 -4
- volcano_sdk/_generated/api/storage_policies/delete_storage_policy.py +79 -7
- volcano_sdk/_generated/models/__init__.py +44 -0
- volcano_sdk/_generated/models/autofix_diagnosis.py +132 -0
- volcano_sdk/_generated/models/autofix_diagnosis_confidence.py +10 -0
- volcano_sdk/_generated/models/autofix_edit.py +75 -0
- volcano_sdk/_generated/models/autofix_evidence.py +82 -0
- volcano_sdk/_generated/models/autofix_evidence_kind.py +10 -0
- volcano_sdk/_generated/models/autofix_patch.py +86 -0
- volcano_sdk/_generated/models/autofix_pull_request.py +131 -0
- volcano_sdk/_generated/models/autofix_pull_request_skipped.py +10 -0
- volcano_sdk/_generated/models/autofix_pull_request_state.py +10 -0
- volcano_sdk/_generated/models/autofix_run.py +362 -0
- volcano_sdk/_generated/models/autofix_run_status.py +10 -0
- volcano_sdk/_generated/models/autofix_run_trigger.py +10 -0
- volcano_sdk/_generated/models/autofix_run_usage.py +83 -0
- volcano_sdk/_generated/models/create_service_key_body.py +3 -1
- volcano_sdk/_generated/models/durable_callback_error.py +70 -0
- volcano_sdk/_generated/models/durable_callback_outcome.py +85 -0
- volcano_sdk/_generated/models/durable_callback_registration.py +110 -0
- volcano_sdk/_generated/models/durable_callback_status.py +10 -0
- volcano_sdk/_generated/models/durable_execution.py +2 -2
- volcano_sdk/_generated/models/fail_durable_callback_request.py +75 -0
- volcano_sdk/_generated/models/function_invocation_request.py +3 -0
- volcano_sdk/_generated/models/function_invocation_request_payload.py +3 -0
- volcano_sdk/_generated/models/heartbeat_durable_callback_request.py +59 -0
- volcano_sdk/_generated/models/paginated_autofix_runs.py +120 -0
- volcano_sdk/_generated/models/project_health_check.py +6 -1
- volcano_sdk/_generated/models/project_health_resource_type.py +2 -2
- volcano_sdk/_generated/models/project_health_response.py +6 -1
- volcano_sdk/_generated/models/project_health_status.py +2 -2
- volcano_sdk/_generated/models/project_health_summary.py +6 -1
- volcano_sdk/_generated/models/register_durable_callback_request.py +87 -0
- volcano_sdk/_generated/models/succeed_durable_callback_request.py +69 -0
- volcano_sdk/_lock_guard.py +12 -5
- volcano_sdk/_path_segments.py +161 -0
- volcano_sdk/_realtime_transport.py +9 -1
- volcano_sdk/_storage_values.py +15 -7
- volcano_sdk/_transport_base.py +120 -10
- volcano_sdk/_transport_database.py +9 -5
- volcano_sdk/_transport_locks.py +6 -5
- volcano_sdk/_transport_sandbox.py +6 -8
- volcano_sdk/_transport_storage.py +31 -25
- volcano_sdk/_user_agent.py +69 -0
- volcano_sdk/durable_authoring.py +93 -6
- volcano_sdk/realtime.py +2 -1
- volcano_sdk/storage.py +25 -15
- {volcano_sdk_python-0.15.1.dist-info → volcano_sdk_python-0.17.0.dist-info}/METADATA +11 -10
- {volcano_sdk_python-0.15.1.dist-info → volcano_sdk_python-0.17.0.dist-info}/RECORD +78 -46
- {volcano_sdk_python-0.15.1.dist-info → volcano_sdk_python-0.17.0.dist-info}/WHEEL +0 -0
- {volcano_sdk_python-0.15.1.dist-info → volcano_sdk_python-0.17.0.dist-info}/licenses/LICENSE +0 -0
volcano_sdk/_auth_oauth.py
CHANGED
|
@@ -11,7 +11,6 @@ from ._auth_values import (
|
|
|
11
11
|
HOSTED_AUTH_ACTIONS,
|
|
12
12
|
INVALID_AUTH_TRANSPORT,
|
|
13
13
|
NO_ACTIVE_SESSION,
|
|
14
|
-
PATH_SEGMENT_SAFE,
|
|
15
14
|
UNSUPPORTED_HOSTED_AUTH_ACTION,
|
|
16
15
|
copy_complete_session,
|
|
17
16
|
hosted_auth_parameter,
|
|
@@ -27,6 +26,7 @@ from ._auth_values import (
|
|
|
27
26
|
validate_hosted_auth_callback_state,
|
|
28
27
|
validate_oauth_callback_state,
|
|
29
28
|
)
|
|
29
|
+
from ._path_segments import path_identifier
|
|
30
30
|
from ._transport import (
|
|
31
31
|
AuthCallOAuthAPITransport,
|
|
32
32
|
AuthGetOAuthProviderTokenTransport,
|
|
@@ -103,7 +103,9 @@ class OAuthAuth(AuthBase):
|
|
|
103
103
|
ValueError: A parameter is empty or the action is unsupported.
|
|
104
104
|
|
|
105
105
|
"""
|
|
106
|
-
project =
|
|
106
|
+
project = path_identifier(
|
|
107
|
+
hosted_auth_parameter(project_id).strip(), "project_id"
|
|
108
|
+
)
|
|
107
109
|
auth_state = hosted_auth_parameter(state)
|
|
108
110
|
if action not in HOSTED_AUTH_ACTIONS:
|
|
109
111
|
raise ValueError(UNSUPPORTED_HOSTED_AUTH_ACTION)
|
|
@@ -114,7 +116,7 @@ class OAuthAuth(AuthBase):
|
|
|
114
116
|
"state": auth_state,
|
|
115
117
|
}
|
|
116
118
|
)
|
|
117
|
-
project_path = quote(project
|
|
119
|
+
project_path = quote(project)
|
|
118
120
|
return (
|
|
119
121
|
f"{self._client.api_base_url()}/projects/{project_path}/auth/hosted?{query}"
|
|
120
122
|
)
|
volcano_sdk/_auth_values.py
CHANGED
|
@@ -137,9 +137,6 @@ OAUTH_API_METHODS: frozenset[str] = frozenset({"GET", "POST"})
|
|
|
137
137
|
HOSTED_AUTH_ACTIONS: frozenset[str] = frozenset({"login", "signup", "forgot-password"})
|
|
138
138
|
|
|
139
139
|
|
|
140
|
-
PATH_SEGMENT_SAFE = ""
|
|
141
|
-
|
|
142
|
-
|
|
143
140
|
def is_non_empty_string(value: object) -> bool:
|
|
144
141
|
return isinstance(value, str) and bool(value.strip())
|
|
145
142
|
|
|
@@ -5,6 +5,8 @@ from __future__ import annotations
|
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
from uuid import UUID
|
|
7
7
|
|
|
8
|
+
from ._path_segments import path_identifier
|
|
9
|
+
|
|
8
10
|
if TYPE_CHECKING:
|
|
9
11
|
from collections.abc import Mapping
|
|
10
12
|
|
|
@@ -15,6 +17,9 @@ _INVALID_IDENTIFIERS = {
|
|
|
15
17
|
"execution_id": "execution_id must be a non-empty string",
|
|
16
18
|
"approval_id": "approval_id must be a non-empty string",
|
|
17
19
|
}
|
|
20
|
+
# The identifiers sent as URL path segments; an execution name is sent in
|
|
21
|
+
# the X-Volcano-Execution-Name header.
|
|
22
|
+
_PATH_IDENTIFIERS = frozenset(_INVALID_IDENTIFIERS) - {"execution_name"}
|
|
18
23
|
# The identifiers the transport converts to a UUID before sending. Checked
|
|
19
24
|
# here so a malformed one is a facade ValidationError rather than a
|
|
20
25
|
# `badly formed hexadecimal UUID string` raised from inside the transport,
|
|
@@ -46,6 +51,8 @@ def identifier(value: object, field: str) -> str:
|
|
|
46
51
|
if not isinstance(value, str) or not value.strip():
|
|
47
52
|
raise ValueError(_INVALID_IDENTIFIERS[field])
|
|
48
53
|
trimmed = value.strip()
|
|
54
|
+
if field in _PATH_IDENTIFIERS:
|
|
55
|
+
trimmed = path_identifier(trimmed, field)
|
|
49
56
|
if field not in _UUID_IDENTIFIERS:
|
|
50
57
|
return trimmed
|
|
51
58
|
try:
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"""Hand a waiting step to another system, with a token Volcano issues for it."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
import inspect
|
|
7
|
+
from typing import TYPE_CHECKING
|
|
8
|
+
|
|
9
|
+
from ._durable_callback import is_mapping
|
|
10
|
+
from ._durable_platform_request import PlatformRequest, post_to_platform
|
|
11
|
+
from ._durable_response import json_value
|
|
12
|
+
from ._transport_response import plain_json
|
|
13
|
+
from ._transport_types import decode_json
|
|
14
|
+
from .errors import ConflictError
|
|
15
|
+
|
|
16
|
+
if TYPE_CHECKING:
|
|
17
|
+
from collections.abc import Callable
|
|
18
|
+
|
|
19
|
+
from .models import JSONValue
|
|
20
|
+
|
|
21
|
+
_NOT_READY = "callback_not_ready"
|
|
22
|
+
_CLOSED = "callback_closed"
|
|
23
|
+
_UNREADABLE_REGISTRATION = (
|
|
24
|
+
"Volcano registered the callback with a token this SDK cannot read"
|
|
25
|
+
)
|
|
26
|
+
_UNREADABLE_RESULT = "Volcano resumed the callback with a result this SDK cannot read"
|
|
27
|
+
SYNCHRONOUS_SUBMITTER = (
|
|
28
|
+
"wait_for_callback() requires a synchronous submitter; "
|
|
29
|
+
"nothing would run an async one's hand-off"
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class CallbackFailedError(Exception):
|
|
34
|
+
"""Raised by `ctx.wait_for_callback` when the token's holder fails it.
|
|
35
|
+
|
|
36
|
+
`type` and `message` are what it sent. `type` is a name to branch on, such
|
|
37
|
+
as `CardDeclined`.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
def __init__(self, error_type: str, message: str) -> None:
|
|
41
|
+
"""Carry the failure's type and message."""
|
|
42
|
+
super().__init__(message)
|
|
43
|
+
self.type: str = error_type
|
|
44
|
+
self.message: str = message
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def token_submitter(
|
|
48
|
+
api_url: str,
|
|
49
|
+
execution_ref: str,
|
|
50
|
+
name: str,
|
|
51
|
+
hand_off: Callable[[str], object],
|
|
52
|
+
operation_id: str | None = None,
|
|
53
|
+
) -> Callable[[str, object], None]:
|
|
54
|
+
"""Build the runtime's submitter: register the callback, then hand its token on.
|
|
55
|
+
|
|
56
|
+
It runs inside the runtime's checkpointed submitter step, so a replay does
|
|
57
|
+
not register the callback again, and a step that runs again registers the
|
|
58
|
+
same callback and gets the same token. `operation_id` names the operation
|
|
59
|
+
an earlier invocation opened the callback under; see `replayed_operation`.
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
The submitter the runtime calls with the callback's id.
|
|
63
|
+
|
|
64
|
+
"""
|
|
65
|
+
|
|
66
|
+
def submit(callback_id: str, _context: object) -> None:
|
|
67
|
+
token = register_callback(
|
|
68
|
+
api_url, execution_ref, callback_id, name, operation_id
|
|
69
|
+
)
|
|
70
|
+
# A closed callback already timed out or was answered; the wait
|
|
71
|
+
# resumes as it did.
|
|
72
|
+
if token is not None:
|
|
73
|
+
handed_off(hand_off(token))
|
|
74
|
+
|
|
75
|
+
return submit
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def replayed_operation(context: object) -> str | None:
|
|
79
|
+
"""Name the operation an earlier invocation opened the next callback under.
|
|
80
|
+
|
|
81
|
+
Volcano then reads back to that callback rather than only through recent
|
|
82
|
+
history. Call it just before the runtime's `wait_for_callback`: the wait
|
|
83
|
+
runs in a child context named by the operation about to start, and opens
|
|
84
|
+
the callback as that context's first operation. Neither the next operation
|
|
85
|
+
nor the checkpoint is public, so a runtime without them names no operation
|
|
86
|
+
and the registration reads as a first run's does.
|
|
87
|
+
|
|
88
|
+
Returns:
|
|
89
|
+
The callback's operation id, or None when this invocation opens it.
|
|
90
|
+
|
|
91
|
+
"""
|
|
92
|
+
peek = getattr(context, "_peek_next_operation_id", None)
|
|
93
|
+
checkpoint = getattr(getattr(context, "state", None), "get_checkpoint_result", None)
|
|
94
|
+
if not callable(peek) or not callable(checkpoint):
|
|
95
|
+
return None
|
|
96
|
+
operation_id = callback_operation_id(str(peek()))
|
|
97
|
+
existent = getattr(checkpoint(operation_id), "is_existent", None)
|
|
98
|
+
if not callable(existent) or not existent():
|
|
99
|
+
return None
|
|
100
|
+
return operation_id
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def callback_operation_id(child_id: str) -> str:
|
|
104
|
+
"""Name the callback a wait's child context `child_id` opens first.
|
|
105
|
+
|
|
106
|
+
Returns:
|
|
107
|
+
The id the runtime checkpoints the callback under.
|
|
108
|
+
|
|
109
|
+
"""
|
|
110
|
+
return hashlib.blake2b(f"{child_id}-1".encode()).hexdigest()[:64]
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def require_synchronous(submitter: object) -> None:
|
|
114
|
+
"""Refuse an `async def` submitter before its callback opens.
|
|
115
|
+
|
|
116
|
+
Raises:
|
|
117
|
+
TypeError: The submitter is a coroutine function.
|
|
118
|
+
|
|
119
|
+
"""
|
|
120
|
+
if inspect.iscoroutinefunction(submitter):
|
|
121
|
+
raise TypeError(SYNCHRONOUS_SUBMITTER)
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def handed_off(result: object) -> None:
|
|
125
|
+
"""Refuse a hand-off that returned an awaitable rather than running.
|
|
126
|
+
|
|
127
|
+
The runtime calls the submitter on a thread without an event loop, so an
|
|
128
|
+
awaitable it returns would never run.
|
|
129
|
+
|
|
130
|
+
Raises:
|
|
131
|
+
TypeError: The submitter returned an awaitable.
|
|
132
|
+
|
|
133
|
+
"""
|
|
134
|
+
if not inspect.isawaitable(result):
|
|
135
|
+
return
|
|
136
|
+
if inspect.iscoroutine(result):
|
|
137
|
+
result.close()
|
|
138
|
+
raise TypeError(SYNCHRONOUS_SUBMITTER)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def register_callback(
|
|
142
|
+
api_url: str,
|
|
143
|
+
execution_ref: str,
|
|
144
|
+
callback_id: str,
|
|
145
|
+
name: str,
|
|
146
|
+
operation_id: str | None = None,
|
|
147
|
+
) -> str | None:
|
|
148
|
+
"""Ask Volcano for the token that completes the callback.
|
|
149
|
+
|
|
150
|
+
Returns:
|
|
151
|
+
The token, or None when the callback stopped waiting before the
|
|
152
|
+
request landed, normally because its timeout passed first.
|
|
153
|
+
|
|
154
|
+
Raises:
|
|
155
|
+
ConflictError: Volcano refused the callback for another reason, such
|
|
156
|
+
as the step being registered for something else.
|
|
157
|
+
TypeError: Volcano answered without a token this SDK can read.
|
|
158
|
+
|
|
159
|
+
"""
|
|
160
|
+
body: dict[str, JSONValue] = {
|
|
161
|
+
"execution_ref": execution_ref,
|
|
162
|
+
"callback_id": callback_id,
|
|
163
|
+
"name": name,
|
|
164
|
+
}
|
|
165
|
+
if operation_id is not None:
|
|
166
|
+
body["operation_id"] = operation_id
|
|
167
|
+
try:
|
|
168
|
+
answer = post_to_platform(
|
|
169
|
+
api_url, PlatformRequest("/durable-callbacks", body, not_ready=_NOT_READY)
|
|
170
|
+
)
|
|
171
|
+
except ConflictError as error:
|
|
172
|
+
if error.code != _CLOSED:
|
|
173
|
+
raise
|
|
174
|
+
return None
|
|
175
|
+
token = answer.get("token") if is_mapping(answer) else None
|
|
176
|
+
if not isinstance(token, str) or not token:
|
|
177
|
+
raise TypeError(_UNREADABLE_REGISTRATION)
|
|
178
|
+
return token
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
def callback_result(result: object) -> JSONValue:
|
|
182
|
+
"""Read the result the token's holder succeeded the callback with.
|
|
183
|
+
|
|
184
|
+
The runtime hands it back as the JSON document Volcano sent, or already
|
|
185
|
+
decoded.
|
|
186
|
+
|
|
187
|
+
Returns:
|
|
188
|
+
The result, as plain JSON.
|
|
189
|
+
|
|
190
|
+
Raises:
|
|
191
|
+
TypeError: The result is not JSON.
|
|
192
|
+
|
|
193
|
+
"""
|
|
194
|
+
if isinstance(result, (str, bytes)):
|
|
195
|
+
document = result.encode() if isinstance(result, str) else result
|
|
196
|
+
try:
|
|
197
|
+
result = decode_json(document)
|
|
198
|
+
except ValueError as error:
|
|
199
|
+
raise TypeError(_UNREADABLE_RESULT) from error
|
|
200
|
+
return plain_json(json_value(result, _UNREADABLE_RESULT))
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
def callback_failure(data: str | None) -> tuple[str, str] | None:
|
|
204
|
+
"""Read the failure Volcano delivered from the runtime's error data.
|
|
205
|
+
|
|
206
|
+
Volcano sends the failure's type and message as the error's data, because
|
|
207
|
+
on replay the runtime rebuilds the error from its message and data alone.
|
|
208
|
+
|
|
209
|
+
Returns:
|
|
210
|
+
The failure's type and message, or None when the data is not one
|
|
211
|
+
Volcano sent, as for a callback that ended because its execution
|
|
212
|
+
stopped.
|
|
213
|
+
|
|
214
|
+
"""
|
|
215
|
+
if data is None:
|
|
216
|
+
return None
|
|
217
|
+
try:
|
|
218
|
+
value = decode_json(data.encode())
|
|
219
|
+
except ValueError:
|
|
220
|
+
return None
|
|
221
|
+
if not is_mapping(value) or not isinstance(error_type := value.get("type"), str):
|
|
222
|
+
return None
|
|
223
|
+
message = value.get("message")
|
|
224
|
+
return error_type, message if isinstance(message, str) else ""
|
volcano_sdk/_durable_engine.py
CHANGED
|
@@ -31,6 +31,7 @@ if TYPE_CHECKING:
|
|
|
31
31
|
WaitForCallbackConfig,
|
|
32
32
|
)
|
|
33
33
|
from aws_durable_execution_sdk_python.config import Duration as EngineDuration
|
|
34
|
+
from aws_durable_execution_sdk_python.exceptions import CallbackExternalError
|
|
34
35
|
from aws_durable_execution_sdk_python.retries import (
|
|
35
36
|
RetryDecision,
|
|
36
37
|
RetryStrategyConfig,
|
|
@@ -121,6 +122,9 @@ class Engine:
|
|
|
121
122
|
config.WaitForCallbackConfig
|
|
122
123
|
)
|
|
123
124
|
self.callback_timeout_error: type[Exception] = exceptions.CallbackTimeoutError
|
|
125
|
+
self.callback_external_error: type[CallbackExternalError] = (
|
|
126
|
+
exceptions.CallbackExternalError
|
|
127
|
+
)
|
|
124
128
|
|
|
125
129
|
def seconds(self, value: int) -> EngineDuration:
|
|
126
130
|
"""Build the runtime's duration from whole seconds.
|
|
@@ -254,7 +258,9 @@ class Engine:
|
|
|
254
258
|
if options.backoff_rate is not None:
|
|
255
259
|
config.backoff_rate = options.backoff_rate
|
|
256
260
|
|
|
257
|
-
def callback_options(
|
|
261
|
+
def callback_options(
|
|
262
|
+
self, timeout: int | None, heartbeat_timeout: int | None = None
|
|
263
|
+
) -> WaitForCallbackConfig:
|
|
258
264
|
"""Build the runtime's callback options.
|
|
259
265
|
|
|
260
266
|
The submitter is not retried by the runtime: it already retries what is
|
|
@@ -264,11 +270,12 @@ class Engine:
|
|
|
264
270
|
The runtime wait-for-callback configuration.
|
|
265
271
|
|
|
266
272
|
"""
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
273
|
+
config = self.wait_for_callback_config(retry_strategy=self._never_retry())
|
|
274
|
+
if timeout is not None:
|
|
275
|
+
config = replace(config, timeout=self.seconds(timeout))
|
|
276
|
+
if heartbeat_timeout is not None:
|
|
277
|
+
config = replace(config, heartbeat_timeout=self.seconds(heartbeat_timeout))
|
|
278
|
+
return config
|
|
272
279
|
|
|
273
280
|
def map_options(self, options: BatchOptions | None) -> object:
|
|
274
281
|
"""Build the runtime's map options.
|
volcano_sdk/_durable_modules.py
CHANGED
|
@@ -20,7 +20,10 @@ if TYPE_CHECKING:
|
|
|
20
20
|
StepSemantics,
|
|
21
21
|
WaitForCallbackConfig,
|
|
22
22
|
)
|
|
23
|
-
from aws_durable_execution_sdk_python.exceptions import
|
|
23
|
+
from aws_durable_execution_sdk_python.exceptions import (
|
|
24
|
+
CallbackExternalError,
|
|
25
|
+
CallbackTimeoutError,
|
|
26
|
+
)
|
|
24
27
|
from aws_durable_execution_sdk_python.retries import (
|
|
25
28
|
RetryDecision,
|
|
26
29
|
RetryStrategyConfig,
|
|
@@ -97,6 +100,7 @@ class ExceptionsModule(Protocol):
|
|
|
97
100
|
"""Runtime errors the authoring adapter turns into values."""
|
|
98
101
|
|
|
99
102
|
CallbackTimeoutError: type[CallbackTimeoutError]
|
|
103
|
+
CallbackExternalError: type[CallbackExternalError]
|
|
100
104
|
|
|
101
105
|
|
|
102
106
|
@runtime_checkable
|
|
@@ -19,6 +19,7 @@ from ._transport_response import (
|
|
|
19
19
|
unparsed_response,
|
|
20
20
|
)
|
|
21
21
|
from ._transport_types import HTTP_CREATED, HTTP_OK
|
|
22
|
+
from ._user_agent import user_agent_headers
|
|
22
23
|
from .errors import (
|
|
23
24
|
ConflictError,
|
|
24
25
|
NotFoundError,
|
|
@@ -117,7 +118,12 @@ def post_to_platform(api_url: str, request: PlatformRequest) -> object:
|
|
|
117
118
|
"""
|
|
118
119
|
url = f"{api_url.removesuffix('/')}{request.path}"
|
|
119
120
|
content = encode(request.body)
|
|
120
|
-
|
|
121
|
+
caller_headers = {
|
|
122
|
+
name: value
|
|
123
|
+
for name, value in request.headers.items()
|
|
124
|
+
if name.lower() != "user-agent"
|
|
125
|
+
}
|
|
126
|
+
headers = {**_JSON, **caller_headers, **user_agent_headers()}
|
|
121
127
|
deadline = monotonic() + _DEADLINE_SECONDS
|
|
122
128
|
timeout = _REQUEST_TIMEOUT_SECONDS
|
|
123
129
|
for delay in _RETRY_DELAYS:
|
|
@@ -9,6 +9,8 @@ from typing_extensions import TypeVar
|
|
|
9
9
|
if TYPE_CHECKING:
|
|
10
10
|
from collections.abc import Callable, Mapping
|
|
11
11
|
|
|
12
|
+
from aws_durable_execution_sdk_python.exceptions import CallbackExternalError
|
|
13
|
+
|
|
12
14
|
from ._durable_options import BatchOptions, Retry, WaitUntilOptions
|
|
13
15
|
|
|
14
16
|
T = TypeVar("T", default=object)
|
|
@@ -53,10 +55,13 @@ class DurableEngine(Protocol):
|
|
|
53
55
|
"""The operations the Volcano facade needs from the optional runtime."""
|
|
54
56
|
|
|
55
57
|
callback_timeout_error: type[Exception]
|
|
58
|
+
callback_external_error: type[CallbackExternalError]
|
|
56
59
|
|
|
57
60
|
def seconds(self, value: int) -> object: ...
|
|
58
61
|
|
|
59
|
-
def callback_options(
|
|
62
|
+
def callback_options(
|
|
63
|
+
self, timeout: int | None, heartbeat_timeout: int | None = None
|
|
64
|
+
) -> object: ...
|
|
60
65
|
|
|
61
66
|
def step_options(self, *, retry: Retry, at_most_once: bool) -> object: ...
|
|
62
67
|
|
|
@@ -11,6 +11,7 @@ from ... import errors
|
|
|
11
11
|
from ...models.auth_forgot_password_body import AuthForgotPasswordBody
|
|
12
12
|
from ...models.auth_forgot_password_response_200 import AuthForgotPasswordResponse200
|
|
13
13
|
from ...models.error import Error
|
|
14
|
+
from ...types import UNSET, Unset
|
|
14
15
|
from typing import cast
|
|
15
16
|
|
|
16
17
|
|
|
@@ -18,9 +19,17 @@ from typing import cast
|
|
|
18
19
|
def request_kwargs(
|
|
19
20
|
*,
|
|
20
21
|
body: AuthForgotPasswordBody,
|
|
22
|
+
x_volcano_proxy_authorization: str | Unset = UNSET,
|
|
23
|
+
x_volcano_client_ip: str | Unset = UNSET,
|
|
21
24
|
|
|
22
25
|
) -> dict[str, Any]:
|
|
23
26
|
headers: dict[str, Any] = {}
|
|
27
|
+
if not isinstance(x_volcano_proxy_authorization, Unset):
|
|
28
|
+
headers["X-Volcano-Proxy-Authorization"] = x_volcano_proxy_authorization
|
|
29
|
+
|
|
30
|
+
if not isinstance(x_volcano_client_ip, Unset):
|
|
31
|
+
headers["X-Volcano-Client-IP"] = x_volcano_client_ip
|
|
32
|
+
|
|
24
33
|
|
|
25
34
|
|
|
26
35
|
|
|
@@ -49,6 +58,13 @@ def _parse_response(*, client: AuthenticatedClient | Client, response: httpx.Res
|
|
|
49
58
|
|
|
50
59
|
return response_200
|
|
51
60
|
|
|
61
|
+
if response.status_code == 401:
|
|
62
|
+
response_401 = Error.from_dict(response.json())
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
return response_401
|
|
67
|
+
|
|
52
68
|
if response.status_code == 403:
|
|
53
69
|
response_403 = Error.from_dict(response.json())
|
|
54
70
|
|
|
@@ -82,6 +98,8 @@ def sync_detailed(
|
|
|
82
98
|
*,
|
|
83
99
|
client: AuthenticatedClient,
|
|
84
100
|
body: AuthForgotPasswordBody,
|
|
101
|
+
x_volcano_proxy_authorization: str | Unset = UNSET,
|
|
102
|
+
x_volcano_client_ip: str | Unset = UNSET,
|
|
85
103
|
|
|
86
104
|
) -> Response[AuthForgotPasswordResponse200 | Error]:
|
|
87
105
|
""" Request password reset
|
|
@@ -91,6 +109,8 @@ def sync_detailed(
|
|
|
91
109
|
Project is identified via the anon key.
|
|
92
110
|
|
|
93
111
|
Args:
|
|
112
|
+
x_volcano_proxy_authorization (str | Unset):
|
|
113
|
+
x_volcano_client_ip (str | Unset):
|
|
94
114
|
body (AuthForgotPasswordBody):
|
|
95
115
|
|
|
96
116
|
Raises:
|
|
@@ -104,6 +124,8 @@ def sync_detailed(
|
|
|
104
124
|
|
|
105
125
|
kwargs = request_kwargs(
|
|
106
126
|
body=body,
|
|
127
|
+
x_volcano_proxy_authorization=x_volcano_proxy_authorization,
|
|
128
|
+
x_volcano_client_ip=x_volcano_client_ip,
|
|
107
129
|
|
|
108
130
|
)
|
|
109
131
|
|
|
@@ -117,6 +139,8 @@ def sync(
|
|
|
117
139
|
*,
|
|
118
140
|
client: AuthenticatedClient,
|
|
119
141
|
body: AuthForgotPasswordBody,
|
|
142
|
+
x_volcano_proxy_authorization: str | Unset = UNSET,
|
|
143
|
+
x_volcano_client_ip: str | Unset = UNSET,
|
|
120
144
|
|
|
121
145
|
) -> AuthForgotPasswordResponse200 | Error | None:
|
|
122
146
|
""" Request password reset
|
|
@@ -126,6 +150,8 @@ def sync(
|
|
|
126
150
|
Project is identified via the anon key.
|
|
127
151
|
|
|
128
152
|
Args:
|
|
153
|
+
x_volcano_proxy_authorization (str | Unset):
|
|
154
|
+
x_volcano_client_ip (str | Unset):
|
|
129
155
|
body (AuthForgotPasswordBody):
|
|
130
156
|
|
|
131
157
|
Raises:
|
|
@@ -140,6 +166,8 @@ def sync(
|
|
|
140
166
|
return sync_detailed(
|
|
141
167
|
client=client,
|
|
142
168
|
body=body,
|
|
169
|
+
x_volcano_proxy_authorization=x_volcano_proxy_authorization,
|
|
170
|
+
x_volcano_client_ip=x_volcano_client_ip,
|
|
143
171
|
|
|
144
172
|
).parsed
|
|
145
173
|
|
|
@@ -147,6 +175,8 @@ async def asyncio_detailed(
|
|
|
147
175
|
*,
|
|
148
176
|
client: AuthenticatedClient,
|
|
149
177
|
body: AuthForgotPasswordBody,
|
|
178
|
+
x_volcano_proxy_authorization: str | Unset = UNSET,
|
|
179
|
+
x_volcano_client_ip: str | Unset = UNSET,
|
|
150
180
|
|
|
151
181
|
) -> Response[AuthForgotPasswordResponse200 | Error]:
|
|
152
182
|
""" Request password reset
|
|
@@ -156,6 +186,8 @@ async def asyncio_detailed(
|
|
|
156
186
|
Project is identified via the anon key.
|
|
157
187
|
|
|
158
188
|
Args:
|
|
189
|
+
x_volcano_proxy_authorization (str | Unset):
|
|
190
|
+
x_volcano_client_ip (str | Unset):
|
|
159
191
|
body (AuthForgotPasswordBody):
|
|
160
192
|
|
|
161
193
|
Raises:
|
|
@@ -169,6 +201,8 @@ async def asyncio_detailed(
|
|
|
169
201
|
|
|
170
202
|
kwargs = request_kwargs(
|
|
171
203
|
body=body,
|
|
204
|
+
x_volcano_proxy_authorization=x_volcano_proxy_authorization,
|
|
205
|
+
x_volcano_client_ip=x_volcano_client_ip,
|
|
172
206
|
|
|
173
207
|
)
|
|
174
208
|
|
|
@@ -182,6 +216,8 @@ async def asyncio(
|
|
|
182
216
|
*,
|
|
183
217
|
client: AuthenticatedClient,
|
|
184
218
|
body: AuthForgotPasswordBody,
|
|
219
|
+
x_volcano_proxy_authorization: str | Unset = UNSET,
|
|
220
|
+
x_volcano_client_ip: str | Unset = UNSET,
|
|
185
221
|
|
|
186
222
|
) -> AuthForgotPasswordResponse200 | Error | None:
|
|
187
223
|
""" Request password reset
|
|
@@ -191,6 +227,8 @@ async def asyncio(
|
|
|
191
227
|
Project is identified via the anon key.
|
|
192
228
|
|
|
193
229
|
Args:
|
|
230
|
+
x_volcano_proxy_authorization (str | Unset):
|
|
231
|
+
x_volcano_client_ip (str | Unset):
|
|
194
232
|
body (AuthForgotPasswordBody):
|
|
195
233
|
|
|
196
234
|
Raises:
|
|
@@ -205,5 +243,7 @@ async def asyncio(
|
|
|
205
243
|
return (await asyncio_detailed(
|
|
206
244
|
client=client,
|
|
207
245
|
body=body,
|
|
246
|
+
x_volcano_proxy_authorization=x_volcano_proxy_authorization,
|
|
247
|
+
x_volcano_client_ip=x_volcano_client_ip,
|
|
208
248
|
|
|
209
249
|
)).parsed
|