@@ -75,6 +75,26 @@ def __init__(self, func: Callable[..., Any], script_file: str):
7575 self .http_type = 'function'
7676 self ._is_http_function = False
7777
78+ def __str__ (self ):
79+ """Return the function.json representation of the function"""
80+ return self .get_function_json ()
81+
82+ def __call__ (self , * args , ** kwargs ):
83+ """This would allow the Function object to be directly callable and runnable
84+ directly using the interpreter locally.
85+
86+ Example:
87+ @app.route(route="http_trigger")
88+ def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
89+ return "Hello, World!"
90+
91+ print(http_trigger(None))
92+
93+ ➜ python function_app.py
94+ Hello, World!
95+ """
96+ return self ._func (* args , ** kwargs )
97+
7898 def add_binding (self , binding : Binding ) -> None :
7999 """Add a binding instance to the function.
80100
@@ -201,17 +221,15 @@ def get_function_json(self) -> str:
201221 """
202222 return json .dumps (self .get_dict_repr (), cls = StringifyEnumJsonEncoder )
203223
204- def __str__ (self ):
205- return self .get_function_json ()
206-
207224
208225class FunctionBuilder (object ):
209226
210227 def __init__ (self , func , function_script_file ):
211228 self ._function = Function (func , function_script_file )
212229
213230 def __call__ (self , * args , ** kwargs ):
214- pass
231+ """Call the Function object directly"""
232+ return self ._function (* args , ** kwargs )
215233
216234 def configure_http_type (self , http_type : str ) -> 'FunctionBuilder' :
217235 self ._function .set_http_type (http_type )
0 commit comments