Skip to content

Commit 51af3e6

Browse files
authored
💥 Breaking Change - Make static_details and static_summary lazy on the workflow description (#869)
* Make static_details and static_summary lazy on the workflow description * Linting * Remove vscode file * Fix test to use methods
1 parent b0aae9b commit 51af3e6

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

‎temporalio/client.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2926,27 +2926,43 @@ class WorkflowExecutionDescription(WorkflowExecution):
29262926

29272927
raw_description: temporalio.api.workflowservice.v1.DescribeWorkflowExecutionResponse
29282928
"""Underlying protobuf description."""
2929-
static_summary: Optional[str]
2930-
"""Gets the single-line fixed summary for this workflow execution that may appear in
2931-
UI/CLI. This can be in single-line Temporal markdown format."""
2932-
static_details: Optional[str]
2933-
"""Gets the general fixed details for this workflow execution that may appear in UI/CLI.
2934-
This can be in Temporal markdown format and can span multiple lines."""
2929+
2930+
_static_summary: Optional[str] = None
2931+
_static_details: Optional[str] = None
2932+
_metadata_decoded: bool = False
2933+
2934+
async def static_summary(self) -> Optional[str]:
2935+
"""Gets the single-line fixed summary for this workflow execution that may appear in
2936+
UI/CLI. This can be in single-line Temporal markdown format.
2937+
"""
2938+
if not self._metadata_decoded:
2939+
await self._decode_metadata()
2940+
return self._static_summary
2941+
2942+
async def static_details(self) -> Optional[str]:
2943+
"""Gets the general fixed details for this workflow execution that may appear in UI/CLI.
2944+
This can be in Temporal markdown format and can span multiple lines.
2945+
"""
2946+
if not self._metadata_decoded:
2947+
await self._decode_metadata()
2948+
return self._static_details
2949+
2950+
async def _decode_metadata(self) -> None:
2951+
"""Internal method to decode metadata lazily."""
2952+
self._static_summary, self._static_details = await _decode_user_metadata(
2953+
self.data_converter, self.raw_description.execution_config.user_metadata
2954+
)
2955+
self._metadata_decoded = True
29352956

29362957
@staticmethod
29372958
async def _from_raw_description(
29382959
description: temporalio.api.workflowservice.v1.DescribeWorkflowExecutionResponse,
29392960
converter: temporalio.converter.DataConverter,
29402961
) -> WorkflowExecutionDescription:
2941-
(summ, deets) = await _decode_user_metadata(
2942-
converter, description.execution_config.user_metadata
2943-
)
29442962
return WorkflowExecutionDescription._from_raw_info( # type: ignore
29452963
description.workflow_execution_info,
29462964
converter,
29472965
raw_description=description,
2948-
static_summary=summ,
2949-
static_details=deets,
29502966
)
29512967

29522968

‎tests/worker/test_workflow.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6394,8 +6394,8 @@ async def waiting() -> bool:
63946394
assert timer_summs == {"hi!", "timer2"}
63956395

63966396
describe_r = await handle.describe()
6397-
assert describe_r.static_summary == "cool workflow bro"
6398-
assert describe_r.static_details == "xtremely detailed"
6397+
assert await describe_r.static_summary() == "cool workflow bro"
6398+
assert await describe_r.static_details() == "xtremely detailed"
63996399

64006400

64016401
@workflow.defn

0 commit comments

Comments
 (0)