sfini.execution¶
State-machine execution interfacing.
Executions track state-machine execution history, input, status and (if available) output. You can wait on it to finish, and iterate over its history.
-
class
sfini.execution.
Execution
(name: str, state_machine_arn: str, execution_input: Union[None, bool, str, int, float, List[JSONable], Dict[str, JSONable]] = DefaultParameter(), arn: str = None, *, session: sfini._util.AWSSession = None)[source]¶ Bases:
object
A state-machine execution.
Parameters: - name – name of execution
- state_machine_arn – executed state-machine ARN
- execution_input – execution input (must be JSON-serialisable)
- arn – execution ARN (if known: provided when execution is posted to AWS SFN)
- session – session to use for AWS communication
-
format_history
() → str[source]¶ Format the execution history for printing.
Returns: history formatted
-
classmethod
from_arn
(arn: str, *, session: sfini._util.AWSSession = None) → sfini.execution._execution.Execution[source]¶ Construct an
Execution
from an existing execution.Queries AWS Step Functions for the execution with the given ARN
Parameters: - arn – existing execution ARN
- session – session to use for AWS communication
Returns: described execution
-
classmethod
from_list_item
(item: Dict[str, Union[None, bool, str, int, float, List[JSONable], Dict[str, JSONable]]], *, session: sfini._util.AWSSession = None) → Execution[source]¶ Construct an
Execution
from a response list-item.Parameters: - item – execution list item
- session – session to use for AWS communication
Returns: described execution
-
get_history
() → List[sfini.execution.history.Event][source]¶ List the execution history.
Returns: history of execution events
-
output
¶ Output of execution.
Raises: RuntimeError
– if execution is not yet finished, or execution failed
-
start_date
¶ Execution start time.
-
status
¶ Execution status.
-
stop
(error_code: str = DefaultParameter(), details: str = DefaultParameter())[source]¶ Stop an existing execution.
Parameters: - error_code – stop reason identification
- details – stop reason
Raises: RuntimeError
– if execution is already finished
-
stop_date
¶ Execution stop time.
Raises: RuntimeError
– if execution is not yet finished
-
wait
(raise_on_failure: bool = True, timeout: float = None)[source]¶ Wait for execution to finish.
Parameters: - raise_on_failure – raise error when execution fails
- timeout – time to wait for execution to finish (seconds), default: no time-out
Raises: RuntimeError
– if execution fails, or if time-out is reached before execution finishes