Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ for task in state.tasks:

This library has a slight change in terminology from AWS [SDKs](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/swf.html)/[APIs](https://docs.aws.amazon.com/amazonswf/latest/apireference/Welcome.html)/[docs](https://docs.aws.amazon.com/amazonswf/latest/developerguide/swf-welcome.html):

* Workflow type -> workflow
* Workflow execution -> execution
* Workflow execution `workflowId` -> execution ID
* Activity type -> activity
Expand Down
22 changes: 11 additions & 11 deletions src/swf_typed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
from ._domains import undeprecate_domain
from ._domains import untag_domain

from ._workflows import WorkflowIdFilter
from ._workflows import WorkflowId
from ._workflows import WorkflowInfo
from ._workflows import WorkflowTypeFilter
from ._workflows import WorkflowTypeReference
from ._workflows import WorkflowTypeInfo
from ._workflows import DefaultExecutionConfiguration
from ._workflows import WorkflowDetails

from ._workflows import delete_workflow
from ._workflows import deprecate_workflow
from ._workflows import describe_workflow
from ._workflows import list_workflows
from ._workflows import register_workflow
from ._workflows import undeprecate_workflow
from ._workflows import WorkflowTypeDetails

from ._workflows import delete_workflow_type
from ._workflows import deprecate_workflow_type
from ._workflows import describe_workflow_type
from ._workflows import list_workflow_types
from ._workflows import register_workflow_type
from ._workflows import undeprecate_workflow_type

from ._activities import ActivityIdFilter
from ._activities import ActivityId
Expand Down
10 changes: 6 additions & 4 deletions src/swf_typed/_decisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class StartChildWorkflowExecutionDecision(Decision):

type: t.ClassVar[str] = "StartChildWorkflowExecution"

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Child execution workflow."""

execution: "_executions.CurrentExecutionId"
Expand All @@ -343,7 +343,7 @@ class StartChildWorkflowExecutionDecision(Decision):
def to_api(self):
data = super().to_api()
data["startChildWorkflowExecutionDecisionAttributes"] = decision_attributes = {
"workflowType": self.workflow.to_api(),
"workflowType": self.workflow_type.to_api(),
"workflowId": self.execution.id,
}

Expand Down Expand Up @@ -398,7 +398,7 @@ class DecisionTask(_common.Deserialisable):
execution: "_executions.ExecutionId"
"""Execution which decisions are being made for."""

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Execution workflow."""

_execution_history_iter: t.Iterable["_history.Event"]
Expand Down Expand Up @@ -439,7 +439,9 @@ def from_api(
return cls(
token=data["taskToken"],
execution=_executions.ExecutionId.from_api(data["workflowExecution"]),
workflow=_workflows.WorkflowId.from_api(data["workflowType"]),
workflow_type=_workflows.WorkflowTypeReference.from_api(
data["workflowType"],
),
_execution_history_iter=execution_history_iter,
decision_task_started_execution_history_event_id=data["startedEventId"],
previous_decision_task_started_execution_history_event_id=data.get(
Expand Down
19 changes: 12 additions & 7 deletions src/swf_typed/_executions.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ExecutionInfo(_common.Deserialisable):
execution: ExecutionId
"""Execution ID."""

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Execution workflow."""

started: datetime.datetime
Expand Down Expand Up @@ -114,7 +114,9 @@ def from_api(cls, data) -> "ExecutionInfo":
status_data = data["closeStatus"]
return cls(
execution=ExecutionId.from_api(data["execution"]),
workflow=_workflows.WorkflowId.from_api(data["workflowType"]),
workflow_type=_workflows.WorkflowTypeReference.from_api(
data["workflowType"],
),
started=data["startTimestamp"],
status=ExecutionStatus(status_data),
cancel_requested=data["cancelRequested"],
Expand Down Expand Up @@ -360,11 +362,14 @@ def get_api_args(self):
class WorkflowTypeExecutionFilter(ExecutionFilter):
"""Workflow execution filter on execution workflow-type."""

workflow: t.Union["_workflows.WorkflowId", "_workflows.WorkflowIdFilter"]
workflow_type: t.Union[
"_workflows.WorkflowTypeReference",
"_workflows.WorkflowTypeFilter",
]
"""Execution workflow."""

def get_api_args(self):
return {"typeFilter": self.workflow.to_api()}
return {"typeFilter": self.workflow_type.to_api()}


@dataclasses.dataclass
Expand Down Expand Up @@ -646,7 +651,7 @@ def signal_execution(


def start_execution(
workflow: "_workflows.WorkflowId",
workflow_type: "_workflows.WorkflowTypeReference",
execution: CurrentExecutionId,
domain: str,
input: str = None,
Expand All @@ -657,7 +662,7 @@ def start_execution(
"""Start a workflow execution.

Args:
workflow: workflow type for execution
workflow_type: workflow type for execution
execution: execution workflow-ID
domain: domain for execution
input: execution input
Expand All @@ -680,7 +685,7 @@ def start_execution(
response = client.start_workflow_execution(
domain=domain,
workflowId=execution.id,
workflowType=workflow.to_api(),
workflowType=workflow_type.to_api(),
**kw,
)
return ExecutionId(id=execution.id, run_id=response["runId"])
Expand Down
60 changes: 40 additions & 20 deletions src/swf_typed/_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ class ChildWorkflowExecutionCancelledEvent(Event):
execution: "_executions.ExecutionId"
"""Cancelled execution."""

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Child execution workflow type."""

initiated_event_id: int
Expand All @@ -459,7 +459,9 @@ def from_api(cls, data):
id=data["eventId"],
occured=data["eventTimestamp"],
execution=_executions.ExecutionId.from_api(attrs["workflowExecution"]),
workflow=_workflows.WorkflowId.from_api(attrs["workflowType"]),
workflow_type=_workflows.WorkflowTypeReference.from_api(
attrs["workflowType"],
),
initiated_event_id=attrs["initiatedEventId"],
execution_started_event_id=attrs["startedEventId"],
details=attrs.get("details"),
Expand All @@ -475,7 +477,7 @@ class ChildWorkflowExecutionCompletedEvent(Event):
execution: "_executions.ExecutionId"
"""Completed execution."""

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Child execution workflow type."""

initiated_event_id: int
Expand All @@ -497,7 +499,9 @@ def from_api(cls, data):
id=data["eventId"],
occured=data["eventTimestamp"],
execution=_executions.ExecutionId.from_api(attrs["workflowExecution"]),
workflow=_workflows.WorkflowId.from_api(attrs["workflowType"]),
workflow_type=_workflows.WorkflowTypeReference.from_api(
attrs["workflowType"],
),
initiated_event_id=attrs["initiatedEventId"],
execution_started_event_id=attrs["startedEventId"],
execution_result=attrs.get("result"),
Expand All @@ -513,7 +517,7 @@ class ChildWorkflowExecutionFailedEvent(Event):
execution: "_executions.ExecutionId"
"""Failed execution."""

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Child execution workflow type."""

initiated_event_id: int
Expand All @@ -538,7 +542,9 @@ def from_api(cls, data):
id=data["eventId"],
occured=data["eventTimestamp"],
execution=_executions.ExecutionId.from_api(attrs["workflowExecution"]),
workflow=_workflows.WorkflowId.from_api(attrs["workflowType"]),
workflow_type=_workflows.WorkflowTypeReference.from_api(
attrs["workflowType"],
),
initiated_event_id=attrs["initiatedEventId"],
execution_started_event_id=attrs["startedEventId"],
reason=attrs.get("reason"),
Expand All @@ -555,7 +561,7 @@ class ChildWorkflowExecutionStartedEvent(Event):
execution: "_executions.ExecutionId"
"""Started execution."""

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Child execution workflow type."""

initiated_event_id: int
Expand All @@ -571,7 +577,9 @@ def from_api(cls, data):
id=data["eventId"],
occured=data["eventTimestamp"],
execution=_executions.ExecutionId.from_api(attrs["workflowExecution"]),
workflow=_workflows.WorkflowId.from_api(attrs["workflowType"]),
workflow_type=_workflows.WorkflowTypeReference.from_api(
attrs["workflowType"],
),
initiated_event_id=attrs["initiatedEventId"],
)

Expand All @@ -585,7 +593,7 @@ class ChildWorkflowExecutionTerminatedEvent(Event):
execution: "_executions.ExecutionId"
"""Terminated execution."""

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Child execution workflow type."""

initiated_event_id: int
Expand All @@ -604,7 +612,9 @@ def from_api(cls, data):
id=data["eventId"],
occured=data["eventTimestamp"],
execution=_executions.ExecutionId.from_api(attrs["workflowExecution"]),
workflow=_workflows.WorkflowId.from_api(attrs["workflowType"]),
workflow_type=_workflows.WorkflowTypeReference.from_api(
attrs["workflowType"],
),
initiated_event_id=attrs["initiatedEventId"],
execution_started_event_id=attrs["startedEventId"],
)
Expand All @@ -619,7 +629,7 @@ class ChildWorkflowExecutionTimedOutEvent(Event):
execution: "_executions.ExecutionId"
"""Timed-out execution."""

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Child execution workflow type."""

initiated_event_id: int
Expand All @@ -639,7 +649,9 @@ def from_api(cls, data):
id=data["eventId"],
occured=data["eventTimestamp"],
execution=_executions.ExecutionId.from_api(attrs["workflowExecution"]),
workflow=_workflows.WorkflowId.from_api(attrs["workflowType"]),
workflow_type=_workflows.WorkflowTypeReference.from_api(
attrs["workflowType"],
),
initiated_event_id=attrs["initiatedEventId"],
execution_started_event_id=attrs["startedEventId"],
)
Expand Down Expand Up @@ -1384,7 +1396,7 @@ class StartChildWorkflowExecutionFailedEvent(Event):
execution: "_executions.CurrentExecutionId"
"""Execution to be started."""

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Child execution workflow type."""

cause: StartChildExecutionFailureCause
Expand All @@ -1409,7 +1421,9 @@ def from_api(cls, data):
id=data["eventId"],
occured=data["eventTimestamp"],
execution=_executions.CurrentExecutionId.from_api(attrs),
workflow=_workflows.WorkflowId.from_api(attrs["workflowType"]),
workflow_type=_workflows.WorkflowTypeReference.from_api(
attrs["workflowType"],
),
cause=StartChildExecutionFailureCause(attrs["cause"]),
initiated_event_id=attrs["initiatedEventId"],
decision_event_id=attrs["decisionTaskCompletedEventId"],
Expand All @@ -1428,7 +1442,7 @@ class StartChildWorkflowExecutionInitiatedEvent(Event):
execution: "_executions.CurrentExecutionId"
"""Execution to be started."""

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Child execution workflow type."""

execution_configuration: "_executions.PartialExecutionConfiguration"
Expand Down Expand Up @@ -1459,7 +1473,9 @@ def from_api(cls, data):
id=data["eventId"],
occured=data["eventTimestamp"],
execution=_executions.CurrentExecutionId.from_api(attrs),
workflow=_workflows.WorkflowId.from_api(attrs["workflowType"]),
workflow_type=_workflows.WorkflowTypeReference.from_api(
attrs["workflowType"],
),
execution_configuration=config,
decision_event_id=attrs["decisionTaskCompletedEventId"],
execution_input=attrs.get("input"),
Expand Down Expand Up @@ -1673,7 +1689,7 @@ class WorkflowExecutionContinuedAsNewEvent(Event):
guaranteed).
"""

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""New execution workflow type."""

decision_event_id: int
Expand All @@ -1697,7 +1713,9 @@ def from_api(cls, data):
occured=data["eventTimestamp"],
execution_run_id=attrs["newExecutionRunId"],
execution_configuration=config,
workflow=_workflows.WorkflowId.from_api(attrs["workflowType"]),
workflow_type=_workflows.WorkflowTypeReference.from_api(
attrs["workflowType"],
),
decision_event_id=attrs["decisionTaskCompletedEventId"],
execution_input=attrs.get("input"),
execution_tags=attrs.get("tagList"),
Expand Down Expand Up @@ -1771,7 +1789,7 @@ class WorkflowExecutionStartedEvent(Event):

type: t.ClassVar[str] = "WorkflowExecutionStarted"

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Execution workflow type."""

execution_configuration: "_executions.PartialExecutionConfiguration"
Expand Down Expand Up @@ -1805,7 +1823,9 @@ def from_api(cls, data):
return cls(
id=data["eventId"],
occured=data["eventTimestamp"],
workflow=_workflows.WorkflowId.from_api(attrs["workflowType"]),
workflow_type=_workflows.WorkflowTypeReference.from_api(
attrs["workflowType"],
),
execution_configuration=config,
execution_input=attrs.get("input"),
execution_tags=attrs.get("tagList"),
Expand Down
4 changes: 2 additions & 2 deletions src/swf_typed/_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class ChildExecutionState:
execution: "_executions.ExecutionId"
"""Child execution ID."""

workflow: "_workflows.WorkflowId"
workflow_type: "_workflows.WorkflowTypeReference"
"""Child execution workflow."""

status: "_executions.ExecutionStatus"
Expand Down Expand Up @@ -525,7 +525,7 @@ def _process_event(self, event: "_history.Event") -> None:

execution = ChildExecutionState(
execution=event.execution,
workflow=initiation_event.workflow,
workflow_type=initiation_event.workflow_type,
status=_executions.ExecutionStatus.started,
configuration=initiation_event.execution_configuration,
started=event.occured,
Expand Down
Loading
Loading