@@ -247,13 +247,13 @@ def call_http(self, method: str, uri: str, content: Optional[str] = None,
247
247
return task
248
248
249
249
def call_sub_orchestrator (self ,
250
- name : str , input_ : Optional [Any ] = None ,
250
+ name : Union [ str , Callable ] , input_ : Optional [Any ] = None ,
251
251
instance_id : Optional [str ] = None ) -> TaskBase :
252
252
"""Schedule sub-orchestration function named `name` for execution.
253
253
254
254
Parameters
255
255
----------
256
- name: str
256
+ name: Union[ str, Callable]
257
257
The name of the orchestrator function to call.
258
258
input_: Optional[Any]
259
259
The JSON-serializable input to pass to the orchestrator function.
@@ -265,19 +265,30 @@ def call_sub_orchestrator(self,
265
265
Task
266
266
A Durable Task that completes when the called sub-orchestrator completes or fails.
267
267
"""
268
+ if isinstance (name , Callable ) and not isinstance (name , FunctionBuilder ):
269
+ error_message = "The `call_activity` API received a `Callable` without an " \
270
+ "associated Azure Functions trigger-type. " \
271
+ "Please ensure you're using the Python programming model V2 " \
272
+ "and that your activity function is annotated with the `activity_trigger`" \
273
+ "decorator. Otherwise, provide in the name of the activity as a string."
274
+ raise ValueError (error_message )
275
+
276
+ if isinstance (name , FunctionBuilder ):
277
+ name = self ._get_function_name (name , OrchestrationTrigger )
278
+
268
279
action = CallSubOrchestratorAction (name , input_ , instance_id )
269
280
task = self ._generate_task (action )
270
281
return task
271
282
272
283
def call_sub_orchestrator_with_retry (self ,
273
- name : str , retry_options : RetryOptions ,
284
+ name : Union [ str , Callable ] , retry_options : RetryOptions ,
274
285
input_ : Optional [Any ] = None ,
275
286
instance_id : Optional [str ] = None ) -> TaskBase :
276
287
"""Schedule sub-orchestration function named `name` for execution, with retry-options.
277
288
278
289
Parameters
279
290
----------
280
- name: str
291
+ name: Union[ str, Callable]
281
292
The name of the activity function to schedule.
282
293
retry_options: RetryOptions
283
294
The settings for retrying this sub-orchestrator in case of a failure.
@@ -291,6 +302,17 @@ def call_sub_orchestrator_with_retry(self,
291
302
Task
292
303
A Durable Task that completes when the called sub-orchestrator completes or fails.
293
304
"""
305
+ if isinstance (name , Callable ) and not isinstance (name , FunctionBuilder ):
306
+ error_message = "The `call_activity` API received a `Callable` without an " \
307
+ "associated Azure Functions trigger-type. " \
308
+ "Please ensure you're using the Python programming model V2 " \
309
+ "and that your activity function is annotated with the `activity_trigger`" \
310
+ "decorator. Otherwise, provide in the name of the activity as a string."
311
+ raise ValueError (error_message )
312
+
313
+ if isinstance (name , FunctionBuilder ):
314
+ name = self ._get_function_name (name , OrchestrationTrigger )
315
+
294
316
action = CallSubOrchestratorWithRetryAction (name , retry_options , input_ , instance_id )
295
317
task = self ._generate_task (action , retry_options )
296
318
return task
0 commit comments