From 942177740e4a18d119db2f2145b91cc1f65fa360 Mon Sep 17 00:00:00 2001 From: Tim Conley Date: Wed, 14 May 2025 10:19:16 -0700 Subject: [PATCH 1/4] Make static_details and static_summary lazy on the workflow description --- temporalio/client.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/temporalio/client.py b/temporalio/client.py index 8381ee69..f53d093e 100644 --- a/temporalio/client.py +++ b/temporalio/client.py @@ -2926,27 +2926,42 @@ class WorkflowExecutionDescription(WorkflowExecution): raw_description: temporalio.api.workflowservice.v1.DescribeWorkflowExecutionResponse """Underlying protobuf description.""" - static_summary: Optional[str] - """Gets the single-line fixed summary for this workflow execution that may appear in - UI/CLI. This can be in single-line Temporal markdown format.""" - static_details: Optional[str] - """Gets the general fixed details for this workflow execution that may appear in UI/CLI. - This can be in Temporal markdown format and can span multiple lines.""" + + _static_summary: Optional[str] = None + _static_details: Optional[str] = None + _metadata_decoded: bool = False + + async def static_summary(self) -> Optional[str]: + """Gets the single-line fixed summary for this workflow execution that may appear in + UI/CLI. This can be in single-line Temporal markdown format.""" + if not self._metadata_decoded: + await self._decode_metadata() + return self._static_summary + + async def static_details(self) -> Optional[str]: + """Gets the general fixed details for this workflow execution that may appear in UI/CLI. + This can be in Temporal markdown format and can span multiple lines.""" + if not self._metadata_decoded: + await self._decode_metadata() + return self._static_details + + async def _decode_metadata(self) -> None: + """Internal method to decode metadata lazily.""" + self._static_summary, self._static_details = await _decode_user_metadata( + self.data_converter, + self.raw_description.execution_config.user_metadata + ) + self._metadata_decoded = True @staticmethod async def _from_raw_description( description: temporalio.api.workflowservice.v1.DescribeWorkflowExecutionResponse, converter: temporalio.converter.DataConverter, ) -> WorkflowExecutionDescription: - (summ, deets) = await _decode_user_metadata( - converter, description.execution_config.user_metadata - ) return WorkflowExecutionDescription._from_raw_info( # type: ignore description.workflow_execution_info, converter, raw_description=description, - static_summary=summ, - static_details=deets, ) From 00b985215951313cc104bf2bb7b468a4832935b3 Mon Sep 17 00:00:00 2001 From: Tim Conley Date: Wed, 14 May 2025 10:39:43 -0700 Subject: [PATCH 2/4] Linting --- .vscode/settings.json | 7 +++++++ temporalio/client.py | 11 ++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..3e99ede3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "python.testing.pytestArgs": [ + "." + ], + "python.testing.unittestEnabled": false, + "python.testing.pytestEnabled": true +} \ No newline at end of file diff --git a/temporalio/client.py b/temporalio/client.py index f53d093e..cad95235 100644 --- a/temporalio/client.py +++ b/temporalio/client.py @@ -2926,21 +2926,23 @@ class WorkflowExecutionDescription(WorkflowExecution): raw_description: temporalio.api.workflowservice.v1.DescribeWorkflowExecutionResponse """Underlying protobuf description.""" - + _static_summary: Optional[str] = None _static_details: Optional[str] = None _metadata_decoded: bool = False async def static_summary(self) -> Optional[str]: """Gets the single-line fixed summary for this workflow execution that may appear in - UI/CLI. This can be in single-line Temporal markdown format.""" + UI/CLI. This can be in single-line Temporal markdown format. + """ if not self._metadata_decoded: await self._decode_metadata() return self._static_summary async def static_details(self) -> Optional[str]: """Gets the general fixed details for this workflow execution that may appear in UI/CLI. - This can be in Temporal markdown format and can span multiple lines.""" + This can be in Temporal markdown format and can span multiple lines. + """ if not self._metadata_decoded: await self._decode_metadata() return self._static_details @@ -2948,8 +2950,7 @@ async def static_details(self) -> Optional[str]: async def _decode_metadata(self) -> None: """Internal method to decode metadata lazily.""" self._static_summary, self._static_details = await _decode_user_metadata( - self.data_converter, - self.raw_description.execution_config.user_metadata + self.data_converter, self.raw_description.execution_config.user_metadata ) self._metadata_decoded = True From 22d55738287e35a4341e7865ce7f018e93f5cbc8 Mon Sep 17 00:00:00 2001 From: Tim Conley Date: Wed, 14 May 2025 10:40:28 -0700 Subject: [PATCH 3/4] Remove vscode file --- .vscode/settings.json | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 3e99ede3..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "python.testing.pytestArgs": [ - "." - ], - "python.testing.unittestEnabled": false, - "python.testing.pytestEnabled": true -} \ No newline at end of file From 457e732df5a8a5a382693121497e0760c407cb15 Mon Sep 17 00:00:00 2001 From: Tim Conley Date: Wed, 14 May 2025 11:03:21 -0700 Subject: [PATCH 4/4] Fix test to use methods --- tests/worker/test_workflow.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/worker/test_workflow.py b/tests/worker/test_workflow.py index 0696f6ec..a4f79a2f 100644 --- a/tests/worker/test_workflow.py +++ b/tests/worker/test_workflow.py @@ -6394,8 +6394,8 @@ async def waiting() -> bool: assert timer_summs == {"hi!", "timer2"} describe_r = await handle.describe() - assert describe_r.static_summary == "cool workflow bro" - assert describe_r.static_details == "xtremely detailed" + assert await describe_r.static_summary() == "cool workflow bro" + assert await describe_r.static_details() == "xtremely detailed" @workflow.defn