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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

## Unreleased

### Changes

* Rename most symbols to match AWS terminology
* Execution state models are unchanged

### Deprecations

* Timer state `duraction` attribute: use `duration` instead
Expand Down
12 changes: 3 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ See [the full documentation](https://python-swf-typed.readthedocs.io/).
```python
import swf_typed

execution = swf_typed.ExecutionId(id="spam", run_id="abcd1234")
execution_details = swf_typed.describe_execution(execution, domain="eggs")
execution = swf_typed.WorkflowExecution(workflow_id="spam", run_id="abcd1234")
execution_details = swf_typed.describe_workflow_execution(execution, domain="eggs")
print(execution_details.configuration)

events = swf_typed.get_execution_history(execution, domain="eggs")
events = swf_typed.get_workflow_execution_history(execution, domain="eggs")
state = swf_typed.build_state(events)
for task in state.tasks:
print(task.status)
Expand All @@ -49,12 +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
* Activity task -> task
* Activity worker -> worker
* Activity task `activityId` -> task ID

This is to simplify symbol names.
10 changes: 2 additions & 8 deletions docs/src/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ Example

import swf_typed

execution = swf_typed.ExecutionId(id="spam", run_id="abcd1234")
execution_details = swf_typed.describe_execution(execution, domain="eggs")
execution = swf_typed.WorkflowExecution(id="spam", run_id="abcd1234")
execution_details = swf_typed.describe_workflow_execution(execution, domain="eggs")
print(execution_details.configuration)

events = swf_typed.get_execution_history(execution, domain="eggs")
Expand All @@ -68,12 +68,6 @@ 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
* Activity task -> task
* Activity worker -> worker
* Activity task ``activityId`` -> task ID

This is to simplify symbol names.
6 changes: 3 additions & 3 deletions scripts/tools/get-execution-state.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ def get_execution_state(
) -> t.Tuple[str, str, str, str, t.Generator[t.Tuple[str, str, str], None, None]]:
import swf_typed

ref = swf_typed.ExecutionId(id=workflow_id, run_id=run_id)
events = swf_typed.get_execution_history(ref, domain=domain_name)
ref = swf_typed.WorkflowExecution(workflow_id=workflow_id, run_id=run_id)
events = swf_typed.get_workflow_execution_history(ref, domain=domain_name)
state = swf_typed.build_state(events)
return (
state.status.value,
(
state.result
if state.status == swf_typed.ExecutionStatus.completed
if state.status == swf_typed.WorkflowExecutionStatus.completed
else f"[{state.failure_reason}] {state.stop_details}"
),
state.workflow.name,
Expand Down
12 changes: 6 additions & 6 deletions scripts/tools/list-executions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ def list_executions(
import swf_typed

if workflow_version:
workflow_filter = swf_typed.WorkflowTypeExecutionFilter(
workflow_filter = swf_typed.WorkflowTypeWorkflowExecutionFilter(
workflow=swf_typed.WorkflowId(name=workflow_name, version=workflow_version),
)
elif workflow_name:
workflow_filter = swf_typed.WorkflowTypeExecutionFilter(
workflow_filter = swf_typed.WorkflowTypeWorkflowExecutionFilter(
workflow=swf_typed.WorkflowIdFilter(name=workflow_name),
)
else:
Expand All @@ -27,22 +27,22 @@ def list_executions(
datetime.datetime.now(tz=datetime.timezone.utc)
- datetime.timedelta(hours=24)
)
time_filter = swf_typed.StartTimeExecutionFilter(earliest=earliest_started)
time_filter = swf_typed.StartTimeWorkflowExecutionFilter(earliest=earliest_started)

if closed:
executions = swf_typed.list_closed_executions(
executions = swf_typed.list_closed_workflow_executions(
domain=domain_name, time_filter=time_filter, property_filter=workflow_filter
)
else:
executions = swf_typed.list_open_executions(
executions = swf_typed.list_open_workflow_executions(
domain=domain_name,
started_filter=time_filter,
property_filter=workflow_filter,
)

for execution in executions:
yield (
execution.execution.id,
execution.execution.workflow_id,
execution.execution.run_id,
execution.status.value,
execution.workflow.name,
Expand Down
96 changes: 48 additions & 48 deletions src/swf_typed/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""Python interface to SWF."""

from ._activities import (
ActivityDetails,
ActivityId,
ActivityIdFilter,
ActivityInfo,
ActivityType,
ActivityTypeDetails,
ActivityTypeFilter,
ActivityTypeInfo,
DefaultTaskConfiguration,
delete_activity,
deprecate_activity,
describe_activity,
list_activities,
register_activity,
undeprecate_activity,
delete_activity_type,
deprecate_activity_type,
describe_activity_type,
list_activity_types,
register_activity_type,
undeprecate_activity_type,
)
from ._decisions import (
CancelTimerDecision,
Expand Down Expand Up @@ -73,31 +73,31 @@
WorkflowExecutionAlreadyStartedFault,
)
from ._executions import (
ChildExecutionTerminationPolicy,
CloseStatusExecutionFilter,
CloseTimeExecutionFilter,
CurrentExecutionId,
ExecutionConfiguration,
ExecutionDetails,
ExecutionFilter,
ExecutionId,
ExecutionInfo,
ExecutionOpenCounts,
ExecutionStatus,
IdExecutionFilter,
PartialExecutionConfiguration,
StartTimeExecutionFilter,
TagExecutionFilter,
WorkflowTypeExecutionFilter,
describe_execution,
get_number_of_closed_executions,
get_number_of_open_executions,
list_closed_executions,
list_open_executions,
request_cancel_execution,
signal_execution,
start_execution,
terminate_execution,
ChildWorkflowExecutionTerminationPolicy,
CloseStatusWorkflowExecutionFilter,
CloseTimeWorkflowExecutionFilter,
CurrentWorkflowExecution,
IdWorkflowExecutionFilter,
PartialWorkflowExecutionConfiguration,
StartTimeWorkflowExecutionFilter,
TagWorkflowExecutionFilter,
WorkflowExecution,
WorkflowExecutionConfiguration,
WorkflowExecutionDetails,
WorkflowExecutionFilter,
WorkflowExecutionInfo,
WorkflowExecutionOpenCounts,
WorkflowExecutionStatus,
WorkflowTypeWorkflowExecutionFilter,
describe_workflow_execution,
get_number_of_closed_workflow_executions,
get_number_of_open_workflow_executions,
list_closed_workflow_executions,
list_open_workflow_executions,
request_cancel_workflow_execution,
signal_workflow_execution,
start_workflow_execution,
terminate_workflow_execution,
)
from ._history import (
ActivityTaskCancelledEvent,
Expand Down Expand Up @@ -161,8 +161,8 @@
WorkflowExecutionStartedEvent,
WorkflowExecutionTerminatedEvent,
WorkflowExecutionTimedOutEvent,
get_execution_history,
get_last_execution_history_event,
get_last_workflow_execution_history_event,
get_workflow_execution_history,
)
from ._state import (
ChildExecutionState,
Expand All @@ -178,10 +178,10 @@
build_state,
)
from ._tasks import (
ActivityWorkerTask,
Cancelled,
PartialTaskConfiguration,
TaskConfiguration,
WorkerTask,
cancel_task,
complete_task,
fail_task,
Expand All @@ -191,14 +191,14 @@
)
from ._workflows import (
DefaultExecutionConfiguration,
WorkflowDetails,
WorkflowId,
WorkflowIdFilter,
WorkflowInfo,
delete_workflow,
deprecate_workflow,
describe_workflow,
list_workflows,
register_workflow,
undeprecate_workflow,
WorkflowType,
WorkflowTypeDetails,
WorkflowTypeFilter,
WorkflowTypeInfo,
delete_workflow_type,
deprecate_workflow_type,
describe_workflow_type,
list_workflow_types,
register_workflow_type,
undeprecate_workflow_type,
)
2 changes: 1 addition & 1 deletion src/swf_typed/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ def get_duration(start: str, end: str) -> str:

if (
output_results
and state["status"] == _executions.ExecutionStatus.completed.value
and state["status"] == _executions.WorkflowExecutionStatus.completed.value
):
yield f"result: {json.dumps(state.get('result'))}"
elif state.get("failure_reason") or (output_results and state.get("stop_details")):
Expand Down
Loading