Skip to content
6 changes: 3 additions & 3 deletions singlestoredb/apps/_python_udfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@


async def run_udf_app(
replace_existing: bool,
log_level: str = 'error',
kill_existing_app_server: bool = True,
) -> UdfConnectionInfo:
Expand Down Expand Up @@ -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()
Expand Down
13 changes: 12 additions & 1 deletion singlestoredb/functions/ext/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down Expand Up @@ -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
Expand Down