@@ -1619,7 +1619,7 @@ async def terminate(
1619
1619
@overload
1620
1620
async def execute_update (
1621
1621
self ,
1622
- update : temporalio .workflow .UpdateMethodMultiArg [[SelfType ], LocalReturnType ],
1622
+ update : temporalio .workflow .UpdateMethodMultiParam [[SelfType ], LocalReturnType ],
1623
1623
* ,
1624
1624
id : Optional [str ] = None ,
1625
1625
rpc_metadata : Mapping [str , str ] = {},
@@ -1631,7 +1631,7 @@ async def execute_update(
1631
1631
@overload
1632
1632
async def execute_update (
1633
1633
self ,
1634
- update : temporalio .workflow .UpdateMethodMultiArg [
1634
+ update : temporalio .workflow .UpdateMethodMultiParam [
1635
1635
[SelfType , ParamType ], LocalReturnType
1636
1636
],
1637
1637
arg : ParamType ,
@@ -1645,7 +1645,7 @@ async def execute_update(
1645
1645
@overload
1646
1646
async def execute_update (
1647
1647
self ,
1648
- update : temporalio .workflow .UpdateMethodMultiArg [
1648
+ update : temporalio .workflow .UpdateMethodMultiParam [
1649
1649
MultiParamSpec , LocalReturnType
1650
1650
],
1651
1651
* ,
@@ -1784,14 +1784,9 @@ async def _start_update(
1784
1784
) -> WorkflowUpdateHandle :
1785
1785
update_name : str
1786
1786
ret_type = result_type
1787
- if isinstance (update , temporalio .workflow .UpdateMethodMultiArg ):
1787
+ if isinstance (update , temporalio .workflow .UpdateMethodMultiParam ):
1788
1788
defn = update ._defn
1789
- if not defn :
1790
- raise RuntimeError (
1791
- f"Update definition not found on { update .__qualname__ } , "
1792
- "is it decorated with @workflow.update?"
1793
- )
1794
- elif not defn .name :
1789
+ if not defn .name :
1795
1790
raise RuntimeError ("Cannot invoke dynamic update definition" )
1796
1791
# TODO(cretz): Check count/type of args at runtime?
1797
1792
update_name = defn .name
@@ -1801,9 +1796,9 @@ async def _start_update(
1801
1796
1802
1797
return await self ._client ._impl .start_workflow_update (
1803
1798
UpdateWorkflowInput (
1804
- workflow_id = self ._id ,
1799
+ id = self ._id ,
1805
1800
run_id = self ._run_id ,
1806
- update_id = id or "" ,
1801
+ update_id = id ,
1807
1802
update = update_name ,
1808
1803
args = temporalio .common ._arg_or_args (arg , args ),
1809
1804
headers = {},
@@ -3878,7 +3873,7 @@ def __init__(
3878
3873
name : str ,
3879
3874
workflow_id : str ,
3880
3875
* ,
3881
- run_id : Optional [str ] = None ,
3876
+ workflow_run_id : Optional [str ] = None ,
3882
3877
result_type : Optional [Type ] = None ,
3883
3878
):
3884
3879
"""Create a workflow update handle.
@@ -3890,29 +3885,29 @@ def __init__(
3890
3885
self ._id = id
3891
3886
self ._name = name
3892
3887
self ._workflow_id = workflow_id
3893
- self ._run_id = run_id
3888
+ self ._workflow_run_id = workflow_run_id
3894
3889
self ._result_type = result_type
3895
3890
self ._known_result : Optional [temporalio .api .update .v1 .Outcome ] = None
3896
3891
3897
3892
@property
3898
3893
def id (self ) -> str :
3899
- """ID of this Update request"""
3894
+ """ID of this Update request. """
3900
3895
return self ._id
3901
3896
3902
3897
@property
3903
3898
def name (self ) -> str :
3904
- """The name of the Update being invoked"""
3899
+ """The name of the Update being invoked. """
3905
3900
return self ._name
3906
3901
3907
3902
@property
3908
3903
def workflow_id (self ) -> str :
3909
- """The ID of the Workflow targeted by this Update"""
3904
+ """The ID of the Workflow targeted by this Update. """
3910
3905
return self ._workflow_id
3911
3906
3912
3907
@property
3913
- def run_id (self ) -> Optional [str ]:
3914
- """If specified, the specific run of the Workflow targeted by this Update"""
3915
- return self ._run_id
3908
+ def workflow_run_id (self ) -> Optional [str ]:
3909
+ """If specified, the specific run of the Workflow targeted by this Update. """
3910
+ return self ._workflow_run_id
3916
3911
3917
3912
async def result (
3918
3913
self ,
@@ -3934,7 +3929,6 @@ async def result(
3934
3929
TimeoutError: The specified timeout was reached when waiting for the update result.
3935
3930
RPCError: Update result could not be fetched for some other reason.
3936
3931
"""
3937
- outcome : temporalio .api .update .v1 .Outcome
3938
3932
if self ._known_result is not None :
3939
3933
outcome = self ._known_result
3940
3934
return await _update_outcome_to_result (
@@ -3944,23 +3938,20 @@ async def result(
3944
3938
self ._client .data_converter ,
3945
3939
self ._result_type ,
3946
3940
)
3947
- else :
3948
- return await self ._client ._impl .poll_workflow_update (
3949
- PollUpdateWorkflowInput (
3950
- self .workflow_id ,
3951
- self .run_id ,
3952
- self .id ,
3953
- self .name ,
3954
- timeout ,
3955
- {},
3956
- self ._result_type ,
3957
- rpc_metadata ,
3958
- rpc_timeout ,
3959
- )
3960
- )
3961
3941
3962
- def _set_known_result (self , result : temporalio .api .update .v1 .Outcome ) -> None :
3963
- self ._known_result = result
3942
+ return await self ._client ._impl .poll_workflow_update (
3943
+ PollUpdateWorkflowInput (
3944
+ self .workflow_id ,
3945
+ self .workflow_run_id ,
3946
+ self .id ,
3947
+ self .name ,
3948
+ timeout ,
3949
+ {},
3950
+ self ._result_type ,
3951
+ rpc_metadata ,
3952
+ rpc_timeout ,
3953
+ )
3954
+ )
3964
3955
3965
3956
3966
3957
class WorkflowFailureError (temporalio .exceptions .TemporalError ):
@@ -4023,11 +4014,9 @@ def message(self) -> str:
4023
4014
class WorkflowUpdateFailedError (temporalio .exceptions .TemporalError ):
4024
4015
"""Error that occurs when an update fails."""
4025
4016
4026
- def __init__ (self , update_id : str , update_name : str , cause : BaseException ) -> None :
4017
+ def __init__ (self , cause : BaseException ) -> None :
4027
4018
"""Create workflow update failed error."""
4028
4019
super ().__init__ ("Workflow update failed" )
4029
- self ._update_id = update_id
4030
- self ._update_name = update_name
4031
4020
self .__cause__ = cause
4032
4021
4033
4022
@property
@@ -4171,9 +4160,9 @@ class TerminateWorkflowInput:
4171
4160
class UpdateWorkflowInput :
4172
4161
"""Input for :py:meth:`OutboundInterceptor.start_workflow_update`."""
4173
4162
4174
- workflow_id : str
4163
+ id : str
4175
4164
run_id : Optional [str ]
4176
- update_id : str
4165
+ update_id : Optional [ str ]
4177
4166
update : str
4178
4167
args : Sequence [Any ]
4179
4168
wait_for_stage : Optional [
@@ -4787,12 +4776,12 @@ async def start_workflow_update(
4787
4776
req = temporalio .api .workflowservice .v1 .UpdateWorkflowExecutionRequest (
4788
4777
namespace = self ._client .namespace ,
4789
4778
workflow_execution = temporalio .api .common .v1 .WorkflowExecution (
4790
- workflow_id = input .workflow_id ,
4779
+ workflow_id = input .id ,
4791
4780
run_id = input .run_id or "" ,
4792
4781
),
4793
4782
request = temporalio .api .update .v1 .Request (
4794
4783
meta = temporalio .api .update .v1 .Meta (
4795
- update_id = input .update_id ,
4784
+ update_id = input .update_id or "" ,
4796
4785
identity = self ._client .identity ,
4797
4786
),
4798
4787
input = temporalio .api .update .v1 .Input (
@@ -4814,23 +4803,19 @@ async def start_workflow_update(
4814
4803
req , retry = True , metadata = input .rpc_metadata , timeout = input .rpc_timeout
4815
4804
)
4816
4805
except RPCError as err :
4817
- # If the status is INVALID_ARGUMENT, we can assume it's an update
4818
- # failed error
4819
- if err .status == RPCStatusCode .INVALID_ARGUMENT :
4820
- raise WorkflowUpdateFailedError (input .workflow_id , input .update , err )
4821
- else :
4822
- raise
4806
+ raise
4823
4807
4808
+ determined_id = resp .update_ref .update_id
4824
4809
update_handle = WorkflowUpdateHandle (
4825
4810
client = self ._client ,
4826
- id = input . update_id ,
4811
+ id = determined_id ,
4827
4812
name = input .update ,
4828
- workflow_id = input .workflow_id ,
4829
- run_id = input .run_id ,
4813
+ workflow_id = input .id ,
4814
+ workflow_run_id = input .run_id ,
4830
4815
result_type = input .ret_type ,
4831
4816
)
4832
4817
if resp .HasField ("outcome" ):
4833
- update_handle ._set_known_result ( resp .outcome )
4818
+ update_handle ._known_result = resp .outcome
4834
4819
4835
4820
return update_handle
4836
4821
@@ -4869,8 +4854,8 @@ async def poll_loop():
4869
4854
input .ret_type ,
4870
4855
)
4871
4856
except RPCError as err :
4872
- if err .status = = RPCStatusCode .DEADLINE_EXCEEDED :
4873
- continue
4857
+ if err .status ! = RPCStatusCode .DEADLINE_EXCEEDED :
4858
+ raise
4874
4859
4875
4860
# Wait for at most the *overall* timeout
4876
4861
return await asyncio .wait_for (
@@ -5415,8 +5400,6 @@ async def _update_outcome_to_result(
5415
5400
) -> Any :
5416
5401
if outcome .HasField ("failure" ):
5417
5402
raise WorkflowUpdateFailedError (
5418
- id ,
5419
- name ,
5420
5403
await converter .decode_failure (outcome .failure .cause ),
5421
5404
)
5422
5405
if not outcome .success .payloads :
0 commit comments