Skip to content

Commit 5de453c

Browse files
kesmit13claude
andcommitted
Rename collocated UDF package to plugin
Rename the `singlestoredb.functions.ext.collocated` package to `singlestoredb.functions.ext.plugin` and update all related naming: - CLI args: --extension -> --plugin-name, --extension-path -> --search-path - Env vars: EXTERNAL_UDF_* -> PLUGIN_* - Class: FunctionHandler -> Plugin - WIT: singlestore:udf/function-handler -> singlestore:plugin/plugin - WIT world: external-udf -> plugin-server - pyproject.toml entry point updated to new module path Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 87e9253 commit 5de453c

File tree

9 files changed

+48
-48
lines changed

9 files changed

+48
-48
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ dev = [
7575
]
7676

7777
[project.scripts]
78-
python-udf-server = "singlestoredb.functions.ext.collocated.__main__:main"
78+
python-udf-server = "singlestoredb.functions.ext.plugin.__main__:main"
7979

8080
[project.entry-points.pytest11]
8181
singlestoredb = "singlestoredb.pytest"
File renamed without changes.

singlestoredb/functions/ext/collocated/__main__.py renamed to singlestoredb/functions/ext/plugin/__main__.py

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
44
Usage::
55
6-
python -m singlestoredb.functions.ext.collocated \\
7-
--extension myfuncs \\
8-
--extension-path /home/user/libs \\
6+
python -m singlestoredb.functions.ext.plugin \\
7+
--plugin-name myfuncs \\
8+
--search-path /home/user/libs \\
99
--socket /tmp/my-udf.sock
1010
1111
Arguments match the Rust wasm-udf-server CLI for drop-in compatibility.
@@ -26,92 +26,92 @@
2626

2727
def main(argv: Any = None) -> None:
2828
parser = argparse.ArgumentParser(
29-
prog='python -m singlestoredb.functions.ext.collocated',
29+
prog='python -m singlestoredb.functions.ext.plugin',
3030
description='High-performance collocated Python UDF server',
3131
)
3232
parser.add_argument(
33-
'--extension',
34-
default=os.environ.get('EXTERNAL_UDF_EXTENSION', ''),
33+
'--plugin-name',
34+
default=os.environ.get('PLUGIN_NAME', ''),
3535
help=(
3636
'Python module to import (e.g. myfuncs). '
37-
'Env: EXTERNAL_UDF_EXTENSION'
37+
'Env: PLUGIN_NAME'
3838
),
3939
)
4040
parser.add_argument(
41-
'--extension-path',
42-
default=os.environ.get('EXTERNAL_UDF_EXTENSION_PATH', ''),
41+
'--search-path',
42+
default=os.environ.get('PLUGIN_SEARCH_PATH', ''),
4343
help=(
4444
'Colon-separated search dirs for the module. '
45-
'Env: EXTERNAL_UDF_EXTENSION_PATH'
45+
'Env: PLUGIN_SEARCH_PATH'
4646
),
4747
)
4848
parser.add_argument(
4949
'--socket',
5050
default=os.environ.get(
51-
'EXTERNAL_UDF_SOCKET_PATH',
51+
'PLUGIN_SOCKET_PATH',
5252
os.path.join(
5353
tempfile.gettempdir(),
5454
f'singlestore-udf-{os.getpid()}-{secrets.token_hex(4)}.sock',
5555
),
5656
),
5757
help=(
5858
'Unix socket path. '
59-
'Env: EXTERNAL_UDF_SOCKET_PATH'
59+
'Env: PLUGIN_SOCKET_PATH'
6060
),
6161
)
6262
parser.add_argument(
6363
'--n-workers',
6464
type=int,
65-
default=int(os.environ.get('EXTERNAL_UDF_N_WORKERS', '0')),
65+
default=int(os.environ.get('PLUGIN_N_WORKERS', '0')),
6666
help=(
6767
'Worker threads (0 = CPU count). '
68-
'Env: EXTERNAL_UDF_N_WORKERS'
68+
'Env: PLUGIN_N_WORKERS'
6969
),
7070
)
7171
parser.add_argument(
7272
'--max-connections',
7373
type=int,
74-
default=int(os.environ.get('EXTERNAL_UDF_MAX_CONNECTIONS', '32')),
74+
default=int(os.environ.get('PLUGIN_MAX_CONNECTIONS', '32')),
7575
help=(
7676
'Socket backlog. '
77-
'Env: EXTERNAL_UDF_MAX_CONNECTIONS'
77+
'Env: PLUGIN_MAX_CONNECTIONS'
7878
),
7979
)
8080
parser.add_argument(
8181
'--log-level',
82-
default=os.environ.get('EXTERNAL_UDF_LOG_LEVEL', 'info'),
82+
default=os.environ.get('PLUGIN_LOG_LEVEL', 'info'),
8383
choices=['debug', 'info', 'warning', 'error'],
8484
help=(
8585
'Logging level. '
86-
'Env: EXTERNAL_UDF_LOG_LEVEL'
86+
'Env: PLUGIN_LOG_LEVEL'
8787
),
8888
)
8989
parser.add_argument(
9090
'--process-mode',
91-
default=os.environ.get('EXTERNAL_UDF_PROCESS_MODE', 'process'),
91+
default=os.environ.get('PLUGIN_PROCESS_MODE', 'process'),
9292
choices=['thread', 'process'],
9393
help=(
9494
'Concurrency mode: "thread" uses a thread pool, '
9595
'"process" uses pre-fork workers for true CPU '
96-
'parallelism. Env: EXTERNAL_UDF_PROCESS_MODE'
96+
'parallelism. Env: PLUGIN_PROCESS_MODE'
9797
),
9898
)
9999

100100
args = parser.parse_args(argv)
101101

102-
if not args.extension:
102+
if not args.plugin_name:
103103
parser.error(
104-
'--extension is required '
105-
'(or set EXTERNAL_UDF_EXTENSION env var)',
104+
'--plugin-name is required '
105+
'(or set PLUGIN_NAME env var)',
106106
)
107107

108108
# Setup logging
109109
level = getattr(logging, args.log_level.upper())
110110
setup_logging(level)
111111

112112
config = {
113-
'extension': args.extension,
114-
'extension_path': args.extension_path,
113+
'plugin_name': args.plugin_name,
114+
'search_path': args.search_path,
115115
'socket': args.socket,
116116
'n_workers': args.n_workers,
117117
'max_connections': args.max_connections,
File renamed without changes.
File renamed without changes.

singlestoredb/functions/ext/collocated/registry.py renamed to singlestoredb/functions/ext/plugin/registry.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,13 @@ def _discover_udf_functions(self) -> None:
181181
"""Discover @udf functions by scanning sys.modules.
182182
183183
Uses a two-pass approach: first, identify candidate modules
184-
that import FunctionHandler (the convention for UDF modules).
184+
that import Plugin (the convention for UDF modules).
185185
Then extract @udf-decorated functions from those modules.
186186
Modules without a __file__ (built-in/frozen) and stdlib/
187187
infrastructure modules are skipped automatically.
188188
"""
189189
# Import here to avoid circular dependency at module level
190-
from .wasm import FunctionHandler
190+
from .wasm import Plugin
191191

192192
found_modules = []
193193
for mod_name, mod in list(sys.modules.items()):
@@ -200,9 +200,9 @@ def _discover_udf_functions(self) -> None:
200200
continue
201201

202202
# Short-circuit: only scan modules that import
203-
# FunctionHandler (the convention for UDF modules)
203+
# Plugin (the convention for UDF modules)
204204
if not any(
205-
obj is FunctionHandler
205+
obj is Plugin
206206
for obj in vars(mod).values()
207207
):
208208
continue

singlestoredb/functions/ext/collocated/server.py renamed to singlestoredb/functions/ext/plugin/server.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -467,21 +467,21 @@ def _worker_signal_handler(
467467
pass
468468

469469
def _initialize_registry(self) -> FunctionRegistry:
470-
"""Import the extension module and discover @udf functions."""
471-
extension = self.config['extension']
472-
extension_path = self.config.get('extension_path', '')
470+
"""Import the plugin module and discover @udf functions."""
471+
plugin_name = self.config['plugin_name']
472+
search_path = self.config.get('search_path', '')
473473

474-
# Prepend extension path directories to sys.path
475-
if extension_path:
476-
for p in reversed(extension_path.split(':')):
474+
# Prepend search path directories to sys.path
475+
if search_path:
476+
for p in reversed(search_path.split(':')):
477477
p = p.strip()
478478
if p and p not in sys.path:
479479
sys.path.insert(0, p)
480480
logger.info(f'Added to sys.path: {p}')
481481

482-
# Import the extension module
483-
logger.info(f'Importing extension module: {extension}')
484-
importlib.import_module(extension)
482+
# Import the plugin module
483+
logger.info(f'Importing plugin module: {plugin_name}')
484+
importlib.import_module(plugin_name)
485485

486486
# Initialize registry (discovers @udf functions from sys.modules)
487487
registry = FunctionRegistry()
@@ -490,7 +490,7 @@ def _initialize_registry(self) -> FunctionRegistry:
490490
func_count = len(registry.functions)
491491
if func_count == 0:
492492
raise RuntimeError(
493-
f'No @udf functions found after importing {extension!r}',
493+
f'No @udf functions found after importing {plugin_name!r}',
494494
)
495495
logger.info(f'Discovered {func_count} function(s)')
496496
for name in sorted(registry.functions):

singlestoredb/functions/ext/collocated/wasm.py renamed to singlestoredb/functions/ext/plugin/wasm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
"""
22
Thin WIT adapter over FunctionRegistry.
33
4-
This module provides the FunctionHandler class that implements the
5-
singlestore:udf/function-handler WIT interface by delegating to the
4+
This module provides the Plugin class that implements the
5+
singlestore:plugin/plugin WIT interface by delegating to the
66
shared FunctionRegistry in registry.py.
77
"""
88
import logging
@@ -21,8 +21,8 @@
2121
_registry = FunctionRegistry()
2222

2323

24-
class FunctionHandler:
25-
"""Implementation of the singlestore:udf/function-handler interface."""
24+
class Plugin:
25+
"""Implementation of the singlestore:plugin/plugin interface."""
2626

2727
def initialize(self) -> None:
2828
"""Initialize and discover UDF functions from loaded modules."""

wit/udf.wit renamed to wit/plugin.wit

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
package singlestore:udf;
1+
package singlestore:plugin;
22

3-
interface function-handler {
3+
interface plugin {
44
/// Initialize the handler and discover pre-imported UDF modules.
55
/// Must be called before any other functions.
66
initialize: func() -> result<_, string>;
@@ -21,6 +21,6 @@ interface function-handler {
2121
create-function: func(signature: string, code: string, replace: bool) -> result<_, string>;
2222
}
2323

24-
world external-udf {
25-
export function-handler;
24+
world plugin-server {
25+
export plugin;
2626
}

0 commit comments

Comments
 (0)