Skip to content

Commit 71e57e7

Browse files
committed
PR feedback
1 parent 59c5728 commit 71e57e7

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed

temporalio/worker/_workflow.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -552,9 +552,9 @@ def _create_workflow_instance(
552552
priority=temporalio.common.Priority._from_proto(init.priority),
553553
)
554554

555-
previous_run_failure = None
556-
if init.HasField("continued_failure"):
557-
previous_run_failure = init.continued_failure
555+
last_failure = (
556+
init.continued_failure if init.HasField("continued_failure") else None
557+
)
558558

559559
# Create instance from details
560560
det = WorkflowInstanceDetails(
@@ -568,7 +568,7 @@ def _create_workflow_instance(
568568
disable_eager_activity_execution=self._disable_eager_activity_execution,
569569
worker_level_failure_exception_types=self._workflow_failure_exception_types,
570570
last_completion_result=init.last_completion_result,
571-
previous_run_failure=previous_run_failure,
571+
last_failure=last_failure,
572572
)
573573
if defn.sandboxed:
574574
return self._workflow_runner.create_instance(det)

temporalio/worker/_workflow_instance.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class WorkflowInstanceDetails:
145145
disable_eager_activity_execution: bool
146146
worker_level_failure_exception_types: Sequence[Type[BaseException]]
147147
last_completion_result: temporalio.api.common.v1.Payloads
148-
previous_run_failure: Optional[Failure]
148+
last_failure: Optional[Failure]
149149

150150

151151
class WorkflowInstance(ABC):
@@ -324,7 +324,7 @@ def __init__(self, det: WorkflowInstanceDetails) -> None:
324324
self._current_details = ""
325325

326326
self._last_completion_result = det.last_completion_result
327-
self._previous_run_failure = det.previous_run_failure
327+
self._last_failure = det.last_failure
328328

329329
# The versioning behavior of this workflow, as established by annotation or by the dynamic
330330
# config function. Is only set once upon initialization.
@@ -1733,9 +1733,9 @@ def workflow_last_completion_result(
17331733
)
17341734

17351735
def workflow_last_failure(self) -> Optional[BaseException]:
1736-
if self._previous_run_failure:
1736+
if self._last_failure:
17371737
return self._failure_converter.from_failure(
1738-
self._previous_run_failure, self._payload_converter
1738+
self._last_failure, self._payload_converter
17391739
)
17401740

17411741
return None

temporalio/worker/workflow_sandbox/_runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def prepare_workflow(self, defn: temporalio.workflow._Definition) -> None:
8888
disable_eager_activity_execution=False,
8989
worker_level_failure_exception_types=self._worker_level_failure_exception_types,
9090
last_completion_result=Payloads(),
91-
previous_run_failure=Failure(),
91+
last_failure=Failure(),
9292
),
9393
)
9494

temporalio/workflow.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1064,9 +1064,7 @@ def get_current_details() -> str:
10641064

10651065

10661066
def has_last_completion_result() -> bool:
1067-
"""Get the last completion result of the workflow. This be None if there was
1068-
no previous completion or the result was None
1069-
"""
1067+
"""Gets whether there is a last completion result of the workflow."""
10701068
return _Runtime.current().workflow_has_last_completion_result()
10711069

10721070

@@ -1079,15 +1077,15 @@ def get_last_completion_result(type_hint: Type[ParamType]) -> Optional[ParamType
10791077

10801078

10811079
def get_last_completion_result(type_hint: Optional[Type] = None) -> Optional[Any]:
1082-
"""Get the last completion result of the workflow. This be None if there was
1080+
"""Get the result of the last run of the workflow. This will be None if there was
10831081
no previous completion or the result was None. has_last_completion_result()
10841082
can be used to differentiate.
10851083
"""
10861084
return _Runtime.current().workflow_last_completion_result(type_hint)
10871085

10881086

10891087
def get_last_failure() -> Optional[BaseException]:
1090-
"""Get the last failure of the workflow."""
1088+
"""Get the last failure of the workflow if it has run previously."""
10911089
return _Runtime.current().workflow_last_failure()
10921090

10931091

0 commit comments

Comments
 (0)