Step Functions¶
Utilities for working with AWS Step Functions.
ExecutionArn ¶
Bases: ExecutionArn
ARN representation for Step Functions executions.
from_components
classmethod
¶
from_components(
state_machine_name,
execution_name,
region=None,
account_id=None,
)
Create an ExecutionArn from components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_machine_name
|
str
|
The name of the state machine. |
required |
execution_name
|
str
|
The name of the execution. |
required |
region
|
Optional[str]
|
AWS region. Defaults to None (uses default region). |
None
|
account_id
|
Optional[str]
|
AWS account ID. Defaults to None (uses current). |
None
|
Returns:
| Type | Description |
|---|---|
ExecutionArn
|
An ExecutionArn constructed from the components. |
Source code in src/aibs_informatics_aws_utils/stepfn.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
StateMachineArn ¶
Bases: StateMachineArn
ARN representation for Step Functions state machines.
from_components
classmethod
¶
from_components(
state_machine_name, region=None, account_id=None
)
Create a StateMachineArn from components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_machine_name
|
str
|
The name of the state machine. |
required |
region
|
Optional[str]
|
AWS region. Defaults to None (uses default region). |
None
|
account_id
|
Optional[str]
|
AWS account ID. Defaults to None (uses current). |
None
|
Returns:
| Type | Description |
|---|---|
StateMachineArn
|
A StateMachineArn constructed from the components. |
Source code in src/aibs_informatics_aws_utils/stepfn.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | |
build_execution_name ¶
build_execution_name(payload, date=None)
Build a unique execution name from a payload string.
Creates a SHA256 hash of the payload (optionally combined with a date) to generate a deterministic execution name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
str
|
The payload string to hash. |
required |
date
|
Optional[datetime]
|
Optional datetime to include for uniqueness. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If serialization or encoding fails. |
Returns:
| Type | Description |
|---|---|
str
|
A SHA256 hex digest suitable for use as an execution name. |
Source code in src/aibs_informatics_aws_utils/stepfn.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | |
describe_execution ¶
describe_execution(
execution_arn, included_data="ALL_DATA", region=None
)
Describe a Step Functions execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
execution_arn
|
str
|
The ARN of the execution to describe. |
required |
included_data
|
IncludedDataType
|
Data to include. Defaults to "ALL_DATA". |
'ALL_DATA'
|
region
|
Optional[str]
|
AWS region. Defaults to None (uses default region). |
None
|
Returns:
| Type | Description |
|---|---|
DescribeExecutionOutputTypeDef
|
The execution description including status, input, and output. |
Source code in src/aibs_informatics_aws_utils/stepfn.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
get_execution_arn ¶
get_execution_arn(
state_machine_name,
execution_name,
env_base=None,
region=None,
)
Get an execution ARN by state machine and execution name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_machine_name
|
str
|
The name of the state machine. |
required |
execution_name
|
str
|
The name of the execution. |
required |
env_base
|
Optional[EnvBase]
|
Environment base for filtering state machines. |
None
|
region
|
Optional[str]
|
AWS region. Defaults to None (uses default region). |
None
|
Raises:
| Type | Description |
|---|---|
InvalidAmazonResourceNameError
|
If no matching execution is found. |
Returns:
| Type | Description |
|---|---|
ExecutionArn
|
The ExecutionArn for the matching execution. |
Source code in src/aibs_informatics_aws_utils/stepfn.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
get_execution_history ¶
get_execution_history(
execution_arn,
reverse_order=False,
include_execution_data=False,
region=None,
)
Get the execution history for a Step Functions execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
execution_arn
|
Union[ExecutionArn, str]
|
The ARN of the execution. |
required |
reverse_order
|
bool
|
Return events in reverse chronological order. |
False
|
include_execution_data
|
bool
|
Include input/output data in events. |
False
|
region
|
Optional[str]
|
AWS region. Defaults to None (uses default region). |
None
|
Returns:
| Type | Description |
|---|---|
List[HistoryEventTypeDef]
|
List of history events for the execution. |
Source code in src/aibs_informatics_aws_utils/stepfn.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | |
get_state_machine ¶
get_state_machine(name, env_base=None, region=None)
Get a state machine by name suffix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name suffix to match against state machine names. |
required |
env_base
|
Optional[EnvBase]
|
Optional environment base to filter by prefix. |
None
|
region
|
Optional[str]
|
AWS region. Defaults to None (uses default region). |
None
|
Raises:
| Type | Description |
|---|---|
ResourceNotFoundError
|
If no matching state machine is found. |
AttributeError
|
If multiple state machines match the criteria. |
Returns:
| Type | Description |
|---|---|
StateMachineListItemTypeDef
|
The matching state machine metadata. |
Source code in src/aibs_informatics_aws_utils/stepfn.py
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | |
get_state_machines ¶
get_state_machines(env_base=None, region=None)
List all state machines, optionally filtered by environment base.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
env_base
|
Optional[EnvBase]
|
Optional environment base to filter by prefix. |
None
|
region
|
Optional[str]
|
AWS region. Defaults to None (uses default region). |
None
|
Returns:
| Type | Description |
|---|---|
List[StateMachineListItemTypeDef]
|
List of state machine metadata items. |
Source code in src/aibs_informatics_aws_utils/stepfn.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 | |
start_execution ¶
start_execution(
state_machine_name,
state_machine_input,
reuse_existing_execution=False,
execution_name=None,
env_base=None,
region=None,
)
Starts a StepFn Execution
Notes
- The state machine Arn is resolved using the name.
- If ExecutionAlreadyExists and
reuse_existing_execution=False, a unique execution name will be generated using aibs_informatics_core.utils.time.get_current_time().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state_machine_name
|
str
|
Name of state machine to execute |
required |
state_machine_input
|
str
|
Serialized payload input for execution. |
required |
reuse_existing_execution
|
bool
|
Skip if existing execution submitted. Defaults to False. |
False
|
env_base
|
EnvBase
|
environment base. Defaults to None. |
None
|
region
|
str
|
ergion. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
ExecutionArn
|
the execution arn |
Source code in src/aibs_informatics_aws_utils/stepfn.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
stop_execution ¶
stop_execution(
execution_arn, error=None, cause=None, region=None
)
Stop a running Step Functions execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
execution_arn
|
Union[ExecutionArn, str]
|
The ARN of the execution to stop. |
required |
error
|
Optional[str]
|
Optional error code to record. |
None
|
cause
|
Optional[str]
|
Optional cause description to record. |
None
|
region
|
Optional[str]
|
AWS region. Defaults to None (uses default region). |
None
|
Returns:
| Type | Description |
|---|---|
datetime
|
The datetime when the execution was stopped. |
Source code in src/aibs_informatics_aws_utils/stepfn.py
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 | |