Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions singlestoredb/apps/_python_udfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# Keep track of currently running server
_running_server: 'typing.Optional[AwaitableUvicornServer]' = None

# Maximum number of UDFs allowed
MAX_UDFS_LIMIT = 10


async def run_udf_app(
log_level: str = 'error',
Expand Down Expand Up @@ -46,6 +49,13 @@ async def run_udf_app(
udf_suffix = '_test'
app = Application(url=base_url, app_mode='managed', name_suffix=udf_suffix)

if not app.endpoints:
raise ValueError('You must define at least one function.')
if len(app.endpoints) > MAX_UDFS_LIMIT:
raise ValueError(
f'You can only define a maximum of {MAX_UDFS_LIMIT} functions.',
)

config = uvicorn.Config(
app,
host='0.0.0.0',
Expand Down