Skip to content

Commit 420096d

Browse files
authored
Udf envs (#24)
* Start work for Python UDF environments
1 parent b982fec commit 420096d

File tree

9 files changed

+1137
-224
lines changed

9 files changed

+1137
-224
lines changed

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ PyJWT
44
requests
55
setuptools
66
sqlparams
7+
tomli>=1.1.0; python_version < '3.11'
78
wheel

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ install_requires =
2626
setuptools
2727
sqlparams
2828
wheel
29+
tomli>=1.1.0;python_version < '3.11'
2930
python_requires = >=3.8
3031
tests_require =
3132
coverage

singlestoredb/config.py

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
"""SingleStoreDB package options."""
33
import functools
4+
import os
45

56
from . import auth
67
from .utils.config import check_bool # noqa: F401
@@ -266,6 +267,129 @@
266267
)
267268

268269

270+
#
271+
# External function options
272+
#
273+
register_option(
274+
'external_function.url', 'string', check_str, 'http://localhost:8000/invoke',
275+
'Specifies the URL of the external function application.',
276+
environ=['SINGLESTOREDB_EXT_FUNC_URL'],
277+
)
278+
279+
register_option(
280+
'external_function.app_mode', 'string',
281+
functools.partial(
282+
check_str,
283+
valid_values=['remote', 'collocated'],
284+
),
285+
'remote',
286+
'Specifies the mode of operation of the external function application.',
287+
environ=['SINGLESTOREDB_EXT_FUNC_APP_MODE'],
288+
)
289+
290+
register_option(
291+
'external_function.data_format', 'string',
292+
functools.partial(
293+
check_str,
294+
valid_values=['rowdat_1', 'json'],
295+
),
296+
'rowdat_1',
297+
'Specifies the format for the data rows.',
298+
environ=['SINGLESTOREDB_EXT_FUNC_DATA_FORMAT'],
299+
)
300+
301+
register_option(
302+
'external_function.data_version', 'string', check_str, '1.0',
303+
'Specifies the version of the data format.',
304+
environ=['SINGLESTOREDB_EXT_FUNC_DATA_VERSION'],
305+
)
306+
307+
register_option(
308+
'external_function.link_name', 'string', check_str, None,
309+
'Specifies the link name to use for remote external functions.',
310+
environ=['SINGLESTOREDB_EXT_FUNC_LINK_NAME'],
311+
)
312+
313+
register_option(
314+
'external_function.link_config', 'string', check_str, None,
315+
'Specifies the link config in JSON format.',
316+
environ=['SINGLESTOREDB_EXT_FUNC_LINK_CONFIG'],
317+
)
318+
319+
register_option(
320+
'external_function.link_credentials', 'string', check_str, None,
321+
'Specifies the link credentials in JSON format.',
322+
environ=['SINGLESTOREDB_EXT_FUNC_LINK_CREDENTIALS'],
323+
)
324+
325+
register_option(
326+
'external_function.replace_existing', 'bool', check_bool, False,
327+
'Should existing functions be replaced when registering external functions?',
328+
environ=['SINGLESTOREDB_EXT_FUNC_REPLACE_EXISTING'],
329+
)
330+
331+
register_option(
332+
'external_function.socket_path', 'string', check_str, None,
333+
'Specifies the socket path for collocated external functions.',
334+
environ=['SINGLESTOREDB_EXT_FUNC_SOCKET_PATH'],
335+
)
336+
337+
register_option(
338+
'external_function.max_connections', 'int', check_int, 32,
339+
'Specifies the maximum connections in a collocated external function ' +
340+
'before reusing them.',
341+
environ=['SINGLESTOREDB_EXT_FUNC_MAX_CONNECTIONS'],
342+
)
343+
344+
register_option(
345+
'external_function.process_mode', 'string',
346+
functools.partial(
347+
check_str,
348+
valid_values=['thread', 'subprocess'],
349+
),
350+
'subprocess',
351+
'Specifies the method to use for concurrent handlers in ' +
352+
'collocated external functions',
353+
environ=['SINGLESTOREDB_EXT_FUNC_PROCESS_MODE'],
354+
)
355+
356+
register_option(
357+
'external_function.single_thread', 'bool', check_bool, False,
358+
'Should the collocated server run in single-thread mode?',
359+
environ=['SINGLESTOREDB_EXT_FUNC_SINGLE_THREAD'],
360+
)
361+
362+
register_option(
363+
'external_function.log_level', 'string',
364+
functools.partial(
365+
check_str,
366+
valid_values=['info', 'debug', 'warning', 'error'],
367+
),
368+
'info',
369+
'Logging level of external function server.',
370+
environ=['SINGLESTOREDB_EXT_FUNC_LOG_LEVEL'],
371+
)
372+
373+
register_option(
374+
'external_function.connection', 'string', check_str,
375+
os.environ.get('SINGLESTOREDB_URL') or None,
376+
'Specifies the connection string for the database to register functions with.',
377+
environ=['SINGLESTOREDB_EXT_FUNC_CONNECTION'],
378+
)
379+
380+
register_option(
381+
'external_function.host', 'string', check_str, '127.0.0.1',
382+
'Specifies the host to bind the server to.',
383+
environ=['SINGLESTOREDB_EXT_FUNC_HOST'],
384+
)
385+
386+
register_option(
387+
'external_function.port', 'int', check_int, 8000,
388+
'Specifies the port to bind the server to.',
389+
environ=['SINGLESTOREDB_EXT_FUNC_PORT'],
390+
)
391+
392+
269393
#
270394
# Debugging options
271395
#
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
#!/usr/bin/env python3
2-
from .asgi import create_app # noqa: F401

0 commit comments

Comments
 (0)