55"""
66from typing import Callable , Iterator , Any , Generator
77
8+ from azure .durable_functions .models .ReplaySchema import ReplaySchema
9+
810from .models import (
911 DurableOrchestrationContext ,
1012 Task ,
@@ -55,6 +57,7 @@ def handle(self, context: DurableOrchestrationContext):
5557 # `fn_output` is the return value instead of a generator
5658 if not isinstance (fn_output , Iterator ):
5759 orchestration_state = OrchestratorState (
60+ replay_schema = self .durable_context ._replay_schema ,
5861 is_done = True ,
5962 output = fn_output ,
6063 actions = self .durable_context .actions ,
@@ -75,6 +78,7 @@ def handle(self, context: DurableOrchestrationContext):
7578 # `will_continue_as_new` essentially "tracks"
7679 # whether or not the orchestration is done.
7780 orchestration_state = OrchestratorState (
81+ replay_schema = self .durable_context ._replay_schema ,
7882 is_done = self .durable_context .will_continue_as_new ,
7983 output = None ,
8084 actions = self .durable_context .actions ,
@@ -95,13 +99,15 @@ def handle(self, context: DurableOrchestrationContext):
9599
96100 except StopIteration as sie :
97101 orchestration_state = OrchestratorState (
102+ replay_schema = self .durable_context ._replay_schema ,
98103 is_done = True ,
99104 output = sie .value ,
100105 actions = self .durable_context .actions ,
101106 custom_status = self .durable_context .custom_status )
102107 except Exception as e :
103108 exception_str = str (e )
104109 orchestration_state = OrchestratorState (
110+ replay_schema = self .durable_context ._replay_schema ,
105111 is_done = False ,
106112 output = None , # Should have no output, after generation range
107113 actions = self .durable_context .actions ,
@@ -135,12 +141,17 @@ def _add_to_actions(self, generation_state):
135141 if self .durable_context .will_continue_as_new :
136142 return
137143 if not generation_state ._is_yielded :
138- if (isinstance (generation_state , Task )
139- and hasattr (generation_state , "action" )):
140- self .durable_context .actions .append ([generation_state .action ])
141- elif (isinstance (generation_state , TaskSet )
142- and hasattr (generation_state , "actions" )):
143- self .durable_context .actions .append (generation_state .actions )
144+ if isinstance (generation_state , Task ):
145+ if self .durable_context ._replay_schema == ReplaySchema .V1 :
146+ self .durable_context .actions .append ([generation_state .action ])
147+ else :
148+ self .durable_context .actions [0 ].append (generation_state .action )
149+
150+ elif isinstance (generation_state , TaskSet ):
151+ if self .durable_context ._replay_schema == ReplaySchema .V1 :
152+ self .durable_context .actions .append (generation_state .actions )
153+ else :
154+ self .durable_context .actions [0 ].append (generation_state .actions )
144155 generation_state ._is_yielded = True
145156
146157 def _update_timestamp (self ):
0 commit comments