Skip to content

Commit 2ca269e

Browse files
committed
Eliminate base serialization context class
1 parent 3316afb commit 2ca269e

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

temporalio/converter.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,7 @@ class SerializationContext(ABC):
9393

9494

9595
@dataclass(frozen=True)
96-
class BaseWorkflowSerializationContext(SerializationContext):
97-
"""Base serialization context shared by workflow and activity serialization contexts."""
98-
99-
namespace: str
100-
workflow_id: Optional[str]
101-
"""Workflow ID."""
102-
103-
104-
@dataclass(frozen=True)
105-
class WorkflowSerializationContext(BaseWorkflowSerializationContext):
96+
class WorkflowSerializationContext(SerializationContext):
10697
"""Serialization context for workflows.
10798
10899
See :py:class:`SerializationContext` for more details.
@@ -115,40 +106,51 @@ class WorkflowSerializationContext(BaseWorkflowSerializationContext):
115106
when the workflow is created by the schedule.
116107
"""
117108

118-
pass
109+
namespace: str
110+
"""Namespace."""
111+
112+
workflow_id: Optional[str]
113+
"""Workflow ID."""
119114

120115

121116
@dataclass(frozen=True)
122-
class ActivitySerializationContext(BaseWorkflowSerializationContext):
117+
class ActivitySerializationContext(SerializationContext):
123118
"""Serialization context for activities.
124119
125120
See :py:class:`SerializationContext` for more details.
126121
127122
Attributes:
128123
namespace: Workflow/activity namespace.
129-
workflow_id: Workflow ID. Note, when creating/describing schedules,
124+
activity_id: Activity ID. Optional if this is an activity started from a workflow.
125+
activity_type: Activity type.
126+
activity_task_queue: Activity task queue.
127+
workflow_id: Workflow ID. Only set if this is an activity started from a workflow. Note, when creating/describing schedules,
130128
this may be the workflow ID prefix as configured, not the final workflow ID when the
131129
workflow is created by the schedule.
132-
workflow_type: Workflow Type.
133-
activity_type: Activity Type.
134-
activity_task_queue: Activity task queue.
135-
is_local: Whether the activity is a local activity.
130+
workflow_type: Workflow Type. Only set if this is an activity started from a workflow.
131+
is_local: Whether the activity is a local activity. False if this is a standalone activity started directly by a client.
136132
"""
137133

138-
workflow_type: Optional[str]
139-
"""Workflow type."""
134+
namespace: str
135+
"""Namespace."""
136+
137+
activity_id: Optional[str]
138+
"""Activity ID. Optional if this is an activity started from a workflow."""
140139

141140
activity_type: str
142141
"""Activity type."""
143142

144-
activity_id: Optional[str]
145-
"""Activity ID."""
146-
147143
activity_task_queue: str
148144
"""Activity task queue."""
149145

146+
workflow_id: Optional[str]
147+
"""Workflow ID if this is an activity started from a workflow."""
148+
149+
workflow_type: Optional[str]
150+
"""Workflow type if this is an activity started from a workflow."""
151+
150152
is_local: bool
151-
"""Whether the activity is a local activity."""
153+
"""Whether the activity is a local activity started from a workflow."""
152154

153155

154156
class WithSerializationContext(ABC):

0 commit comments

Comments
 (0)