diff --git a/temporalio/worker/_workflow_instance.py b/temporalio/worker/_workflow_instance.py index c33796ef..5f24d684 100644 --- a/temporalio/worker/_workflow_instance.py +++ b/temporalio/worker/_workflow_instance.py @@ -1023,6 +1023,9 @@ def workflow_get_update_validator(self, name: Optional[str]) -> Optional[Callabl def workflow_info(self) -> temporalio.workflow.Info: return self._outbound.info() + def workflow_instance(self) -> Any: + return self._object + def workflow_is_continue_as_new_suggested(self) -> bool: return self._continue_as_new_suggested diff --git a/temporalio/workflow.py b/temporalio/workflow.py index 6351bace..bf57e928 100644 --- a/temporalio/workflow.py +++ b/temporalio/workflow.py @@ -625,6 +625,9 @@ def workflow_get_update_validator( @abstractmethod def workflow_info(self) -> Info: ... + @abstractmethod + def workflow_instance(self) -> Any: ... + @abstractmethod def workflow_is_continue_as_new_suggested(self) -> bool: ... @@ -818,6 +821,15 @@ def info() -> Info: return _Runtime.current().workflow_info() +def instance() -> Any: + """Current workflow's instance. + + Returns: + The currently running workflow instance. + """ + return _Runtime.current().workflow_instance() + + def memo() -> Mapping[str, Any]: """Current workflow's memo values, converted without type hints.