@@ -247,13 +247,13 @@ def call_http(self, method: str, uri: str, content: Optional[str] = None,
247247 return task
248248
249249 def call_sub_orchestrator (self ,
250- name : str , input_ : Optional [Any ] = None ,
250+ name : Union [ str , Callable ] , input_ : Optional [Any ] = None ,
251251 instance_id : Optional [str ] = None ) -> TaskBase :
252252 """Schedule sub-orchestration function named `name` for execution.
253253
254254 Parameters
255255 ----------
256- name: str
256+ name: Union[ str, Callable]
257257 The name of the orchestrator function to call.
258258 input_: Optional[Any]
259259 The JSON-serializable input to pass to the orchestrator function.
@@ -265,19 +265,30 @@ def call_sub_orchestrator(self,
265265 Task
266266 A Durable Task that completes when the called sub-orchestrator completes or fails.
267267 """
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+
268279 action = CallSubOrchestratorAction (name , input_ , instance_id )
269280 task = self ._generate_task (action )
270281 return task
271282
272283 def call_sub_orchestrator_with_retry (self ,
273- name : str , retry_options : RetryOptions ,
284+ name : Union [ str , Callable ] , retry_options : RetryOptions ,
274285 input_ : Optional [Any ] = None ,
275286 instance_id : Optional [str ] = None ) -> TaskBase :
276287 """Schedule sub-orchestration function named `name` for execution, with retry-options.
277288
278289 Parameters
279290 ----------
280- name: str
291+ name: Union[ str, Callable]
281292 The name of the activity function to schedule.
282293 retry_options: RetryOptions
283294 The settings for retrying this sub-orchestrator in case of a failure.
@@ -291,6 +302,17 @@ def call_sub_orchestrator_with_retry(self,
291302 Task
292303 A Durable Task that completes when the called sub-orchestrator completes or fails.
293304 """
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+
294316 action = CallSubOrchestratorWithRetryAction (name , retry_options , input_ , instance_id )
295317 task = self ._generate_task (action , retry_options )
296318 return task
0 commit comments