Skip to content
Open
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
24 changes: 8 additions & 16 deletions simpleflow/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ def get_activity():
"decision_task_completed_event_id": event.decision_task_completed_event_id,
}
if event.activity_id not in self._activities:
activity["retry"] = 0
activity["attempt"] = 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could use the attempt_number name, as in simpleflow.task.TaskFailureContext?
And update this class not to use retry? 🙂

self._activities[event.activity_id] = activity
self._tasks.append(activity)
else:
Expand All @@ -164,6 +166,8 @@ def get_activity():
# in ``retry``. As the state of the event mutates, it
# corresponds to the last execution.
self._activities[event.activity_id].update(activity)
self._activities[event.activity_id]["retry"] += 1
self._activities[event.activity_id]["attempt"] += 1
elif event.state == "schedule_failed":
activity = {
"type": "activity",
Expand Down Expand Up @@ -218,10 +222,6 @@ def get_activity():
"timed_out_timestamp": event.timestamp,
}
)
if "retry" not in activity:
activity["retry"] = 0
else:
activity["retry"] += 1
elif event.state == "failed":
activity = get_activity()
activity.update(
Expand All @@ -233,10 +233,6 @@ def get_activity():
"failed_timestamp": event.timestamp,
}
)
if "retry" not in activity:
activity["retry"] = 0
else:
activity["retry"] += 1
elif event.state == "cancelled":
activity = get_activity()
activity.update(
Expand Down Expand Up @@ -310,6 +306,8 @@ def get_workflow():
"decision_task_completed_event_id": event.decision_task_completed_event_id,
}
if event.workflow_id not in self._child_workflows:
workflow["retry"] = 0
workflow["attempt"] = 1
self._child_workflows[event.workflow_id] = workflow
self._tasks.append(workflow)
else:
Expand All @@ -322,6 +320,8 @@ def get_workflow():
f" we're @{event.id})"
)
self._child_workflows[event.workflow_id].update(workflow)
self._child_workflows[event.workflow_id]["retry"] += 1
self._child_workflows[event.workflow_id]["attempt"] += 1
elif event.state == "start_failed":
workflow = {
"type": "child_workflow",
Expand Down Expand Up @@ -372,10 +372,6 @@ def get_workflow():
"failed_timestamp": event.timestamp,
}
)
if "retry" not in workflow:
workflow["retry"] = 0
else:
workflow["retry"] += 1
elif event.state == "timed_out":
workflow = get_workflow()
workflow.update(
Expand All @@ -391,10 +387,6 @@ def get_workflow():
"timed_out_timestamp": event.timestamp,
}
)
if "retry" not in workflow:
workflow["retry"] = 0
else:
workflow["retry"] += 1
elif event.state == "canceled":
workflow = get_workflow()
workflow.update(
Expand Down
1 change: 1 addition & 0 deletions simpleflow/swf/mapper/models/event/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class ActivityTaskEventDict(TypedDict):
activity_id: int
activity_type: ActivityType
retry: int | None
attempt: int | None
cause: str
result: Any
reason: str | None
Expand Down