diff --git a/singlestoredb/apps/_python_udfs.py b/singlestoredb/apps/_python_udfs.py index bcbc7a61c..d7bca6d6b 100644 --- a/singlestoredb/apps/_python_udfs.py +++ b/singlestoredb/apps/_python_udfs.py @@ -15,7 +15,6 @@ async def run_udf_app( - replace_existing: bool, log_level: str = 'error', kill_existing_app_server: bool = True, ) -> UdfConnectionInfo: @@ -55,8 +54,9 @@ async def run_udf_app( ) _running_server = AwaitableUvicornServer(config) - # Register the functions - app.register_functions(replace=replace_existing) + # Register the functions only if the app is running interactively. + if app_config.running_interactively: + app.register_functions(replace=True) asyncio.create_task(_running_server.serve()) await _running_server.wait_for_startup() diff --git a/singlestoredb/functions/ext/asgi.py b/singlestoredb/functions/ext/asgi.py index c8ff8f4f5..97997ffc9 100755 --- a/singlestoredb/functions/ext/asgi.py +++ b/singlestoredb/functions/ext/asgi.py @@ -964,6 +964,13 @@ def get_function_info( functions = {} no_default = object() + # Generate CREATE FUNCTION SQL for each function using get_create_functions + create_sqls = self.get_create_functions(replace=True) + sql_map = {} + for (_, info), sql in zip(self.endpoints.values(), create_sqls): + sig = info['signature'] + sql_map[sig['name']] = sql + for key, (_, info) in self.endpoints.items(): if not func_name or key == func_name: sig = info['signature'] @@ -1001,8 +1008,12 @@ def get_function_info( if a.get('default', no_default) is not no_default: returns[-1]['default'] = a['default'] + sql = sql_map.get(sig['name'], '') functions[sig['name']] = dict( - args=args, returns=returns, function_type=info['function_type'], + args=args, + returns=returns, + function_type=info['function_type'], + sql_statement=sql, ) return functions