Skip to content

Commit 7a0f096

Browse files
authored
Add documentation for managing Python UDF packages via SQL in 3.0+ (#527)
1 parent 30282e8 commit 7a0f096

File tree

2 files changed

+124
-15
lines changed

2 files changed

+124
-15
lines changed

docs/py-udf.md

Lines changed: 71 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,52 @@ $$;
171171
```
172172

173173
## Manage Python Libraries {#python_libs}
174-
By default, Timeplus Enterprise ships a clean Python 3.10 environment, plus the following essential libraries:
174+
175+
Starting from Proton/Timeplus Enterprise 3.0, manage Python UDF packages directly via SQL `SYSTEM` commands. This is the only supported flow on 3.0+. The 2.x methods below are not supported on 3.0.
176+
177+
### Install/List/Uninstall via SQL (3.0+) {#install_sql}
178+
Examples:
179+
```sql
180+
-- Install latest
181+
SYSTEM INSTALL PYTHON PACKAGE 'requests';
182+
183+
-- Install with version specifier (PEP 440)
184+
SYSTEM INSTALL PYTHON PACKAGE 'requests>2.0';
185+
SYSTEM INSTALL PYTHON PACKAGE 'requests==2.32.3';
186+
187+
-- Alternative form with separate version literal
188+
SYSTEM INSTALL PYTHON PACKAGE 'requests' '2.32.3';
189+
190+
-- List installed packages
191+
SYSTEM LIST PYTHON PACKAGES;
192+
193+
-- Uninstall
194+
SYSTEM UNINSTALL PYTHON PACKAGE 'requests';
195+
```
196+
197+
Notes:
198+
- Applies to Proton/Enterprise 3.0+ with Python UDF enabled (Python 3.10).
199+
- Cluster-wide operation; requires `SYSTEM RELOAD CONFIG` privilege.
200+
- `SYSTEM LIST PYTHON PACKAGES` returns columns `package_name`, `version`.
201+
- Install/uninstall runs asynchronously. Check status via `system.python_package_tasks`:
202+
```sql
203+
SELECT status, error_code, error_message
204+
FROM system.python_package_tasks
205+
WHERE package_name='requests' AND operation='install'
206+
ORDER BY created_at DESC LIMIT 1;
207+
```
208+
209+
Permissions:
210+
- Built-in users in official Docker images (e.g., `default`, `proton`) typically have this privilege.
211+
- For a new user, grant it explicitly:
212+
```sql
213+
GRANT SYSTEM RELOAD CONFIG ON *.* TO gen;
214+
```
215+
216+
See more: /sql-system-python-packages
217+
218+
### Built-in Libraries
219+
By default, Timeplus ships a clean Python 3.10 environment, plus the following essential libraries:
175220

176221
```json
177222
[
@@ -233,11 +278,15 @@ Follow the guide below to install extra Python libraries. The following librarie
233278

234279
Some Python libraries may require additional dependencies or OS specific packages. Contact us if you need help.
235280

236-
### Install Python Libraries {#install_lib}
237-
To install new Python libraries, you can either call the REST API of timeplusd in Timeplus Enterprise v2.7, or use the new `timeplusd python pip install` command-line tool introduced in Timeplus Enterprise v2.8.
281+
### Install Python Libraries (Legacy 2.x) {#install_lib}
282+
For Enterprise 2.x, you can either call the REST API (2.7+) or use `timeplusd python -m pip` (2.8+).
283+
284+
Important: These legacy methods are not supported on Proton/Enterprise 3.0. Use the SQL `SYSTEM` commands instead.
285+
286+
#### Install via `timeplusd python pip` (2.8) {#install_pip}
287+
Only for Enterprise v2.8. Not available on 3.0+.
238288

239-
#### Install via `timeplusd python pip` {#install_pip}
240-
Starting from Timeplus Enterprise v2.8, you can use the `timeplusd python pip install` command-line tool to install Python libraries. For example, to install the `numpy` library, you can use the following command:
289+
In Enterprise v2.8, you can use the `timeplusd python -m pip` command-line tool to install Python libraries. For example, to install the `numpy` library:
241290
```bash
242291
timeplusd python --config-file ../conf/timeplusd.yaml -m pip install --user numpy
243292
```
@@ -247,9 +296,11 @@ For example, with the timeplusd docker image, you can use the following command:
247296
docker exec -it container_name timeplusd python --config-file /etc/timeplusd-server/config.yaml -m pip install --user pandas
248297
```
249298

250-
#### Install via REST API {#install_rest}
299+
#### Install via REST API (2.7+) {#install_rest}
251300

252-
You can also call the REST API of timeplusd in Timeplus Enterprise v2.7 or above.
301+
Only for Enterprise v2.7–v2.8. Not available on 3.0+.
302+
303+
You can call the REST API of timeplusd in Timeplus Enterprise v2.7+.
253304

254305
:::info
255306
To access the REST API, you need to create an administrator account and set the HTTP headers `x-timeplus-user` and `x-timeplus-key` with the user and password, such as `curl -H "x-timeplus-user: theUser" -H "x-timeplus-key:thePwd" ..`.
@@ -265,24 +316,29 @@ If you need to install a specific version of a library, you can specify it in th
265316
curl -H "x-timeplus-user: theUser" -H "x-timeplus-key:thePwd" -X POST http://localhost:8123/timeplusd/v1/python_packages -d '{"packages": [{"name": "numpy", "version": "2.2.3"}]}'
266317
```
267318

268-
### List Python Libraries {#list_lib}
269-
To list the extra Python libraries installed in Timeplus Enterprise, you can use the following command:
319+
### List Python Libraries (2.x) {#list_lib}
320+
Only for Enterprise v2.7–v2.8. On 3.0+, use `SYSTEM LIST PYTHON PACKAGES`.
321+
322+
To list the extra Python libraries installed in Enterprise 2.x, use the REST API:
270323
```bash
271324
curl -H "x-timeplus-user: theUser" -H "x-timeplus-key:thePwd" http://localhost:8123/timeplusd/v1/python_packages
272325
```
273326

274-
### Delete Python Libraries {#delete_lib}
275-
To delete Python libraries, you can call the REST API of timeplusd in Timeplus Enterprise.
327+
### Delete Python Libraries (2.x) {#delete_lib}
328+
Only for Enterprise v2.7–v2.8. On 3.0+, use `SYSTEM UNINSTALL PYTHON PACKAGE`.
329+
330+
To delete Python libraries in Enterprise 2.x, call the REST API:
276331

277332
For example, if you want to delete the `numpy` library, you can use the following command:
278333
```bash
279334
curl -H "x-timeplus-user: theUser" -H "x-timeplus-key:thePwd" -X DELETE http://localhost:8123/timeplusd/v1/python_packages/numpy
280335
```
281336

282337
### Update Python Libraries {#update_lib}
283-
Currently we don't support updating Python libraries. You can delete the library and reinstall it with the desired version.
338+
There is no in-place update. Uninstall then install the desired version.
284339

285340
## Limitations
286-
- For Linux bare metal deployments, Glibc version 2.35 or higher is required.
287-
- Only Python 3.10 is supported. Contact us if you need to install a specific version.
288-
- Not all Python libraries can be installed in Timeplus Enterprise. Contact us if you need to install a specific library.
341+
- Linux deployments require Glibc 2.35+.
342+
- Python 3.10 only for the embedded runtime.
343+
- Some libraries may require OS/system dependencies.
344+
- On 3.0+, use SQL `SYSTEM` commands; on 2.x, use REST or `timeplusd python -m pip`.

docs/sql-system-python-packages.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# SYSTEM PYTHON PACKAGES
2+
3+
Manage Python UDF dependencies from SQL in Proton/Timeplus Enterprise 3.0+.
4+
5+
## Examples
6+
```sql
7+
-- Install latest
8+
SYSTEM INSTALL PYTHON PACKAGE 'requests';
9+
10+
-- Install with version specifiers (PEP 440)
11+
SYSTEM INSTALL PYTHON PACKAGE 'requests>2.0';
12+
SYSTEM INSTALL PYTHON PACKAGE 'requests==2.32.3';
13+
14+
-- Alternative form with separate version literal
15+
SYSTEM INSTALL PYTHON PACKAGE 'requests' '2.32.3';
16+
17+
-- List installed packages (returns: package_name, version)
18+
SYSTEM LIST PYTHON PACKAGES;
19+
20+
-- Uninstall
21+
SYSTEM UNINSTALL PYTHON PACKAGE 'requests';
22+
```
23+
24+
## Behavior
25+
- Scope: Cluster-wide installation/uninstallation using the UDF runtime’s Python 3.10 environment.
26+
- Permissions: Requires `SYSTEM RELOAD CONFIG` privilege.
27+
- Versioning: Accepts PEP 440 specifiers in the first literal (e.g., `>=`, `==`, `~=`). When using the second literal, provide the exact version string.
28+
- Install location: Uses pip’s user install under the embedded interpreter; no system-level Python changes.
29+
- Async operations: Install/uninstall run asynchronously. Track progress via `system.python_package_tasks`.
30+
31+
Monitor status
32+
```sql
33+
SELECT status, error_code, error_message
34+
FROM system.python_package_tasks
35+
WHERE package_name = 'requests' AND operation = 'install'
36+
ORDER BY created_at DESC
37+
LIMIT 1;
38+
```
39+
40+
List installed packages
41+
```sql
42+
SYSTEM LIST PYTHON PACKAGES; -- columns: package_name, version
43+
```
44+
45+
Granting permissions
46+
```sql
47+
-- Built-in users in official images (e.g., default, proton) typically have it already.
48+
GRANT SYSTEM RELOAD CONFIG ON *.* TO gen;
49+
```
50+
51+
## Compatibility
52+
- Proton/Enterprise 3.0+: Use these SQL commands. This is the only supported method in 3.0+.
53+
- Enterprise 2.x: Use REST API or `timeplusd python -m pip` (see /py-udf#install_lib). These legacy methods are not supported on 3.0+.

0 commit comments

Comments
 (0)