feat: expose structured Function refresh options in SDKs (#5047)

## Problem

ENT-3267 still lacks typed refresh controls for `supervisor_resources`
and `planning_workers` in Python, Rust, and Node, and Node has no
`retry_policy` refresh option. Callers must drop to SQL for those
controls.

## Change

- Add canonical Rust `FunctionRefreshPodResources` and
`FunctionRefreshPlanningConfig`, and serialize them through
`RefreshColumnOptions`.
- Expose both options in the Python sync/async wrappers and PyO3
binding.
- Expose both options in the Node NAPI object and add a Node
`retryPolicy` object backed by the existing Rust `FunctionRetryPolicy`.
- Omitted options stay omitted; branch targeting continues through the
table handle. No server, dependency, or pin changes are included.

Client-side checks only reject non-positive structural values.
Deployment resource limits and column-kind validation remain
server-side.

## Validation

`cargo fmt --all -- --check`, `python3 -m py_compile`, and `git diff
--check` pass. No native build was run locally; CI compiles and tests
the change. Generated JS API pages are unchanged.
This commit is contained in:
Xuanwo
2026-11-14 20:59:44 +08:00
committed by GitHub
parent 4843ac4c7e
commit f6f8119ba4
21 changed files with 1164 additions and 10 deletions
+65
View File
@@ -2076,6 +2076,23 @@ def test_remote_create_index_async_returns_job():
"gpu_count": 2,
}
},
{
"supervisor_resources": {
"cpu_millis": 2000,
"memory_bytes": 4 * 1024**3,
"ephemeral_storage_bytes": 10 * 1024**3,
},
"planning_workers": {
"resources": {
"cpu_millis": 1000,
"memory_bytes": 2 * 1024**3,
"ephemeral_storage_bytes": 5 * 1024**3,
},
"max_workers": 4,
"rows_per_worker": 100_000,
"fragments_per_worker": 8,
},
},
{"gpu_class": "a10g", "gpu_count": 2},
{
"retry_policy": {"transient": True, "max_attempts": 3},
@@ -2122,6 +2139,9 @@ async def test_remote_refresh_async_returns_typed_terminal_result(
**budget,
"gpu_count": budget.get("gpu_count", 0),
}
for key in ("supervisor_resources", "planning_workers"):
if refresh_kwargs.get(key) is not None:
expected[key] = refresh_kwargs[key]
if refresh_kwargs.get("retry_policy") is not None:
expected["retry_policy"] = lancedb.FunctionRetryPolicy.model_validate(
refresh_kwargs["retry_policy"]
@@ -2350,6 +2370,51 @@ def test_remote_refresh_async_forwards_progress_from_submitted_handle():
},
"unsupported key 'unknown'",
),
(
{
"supervisor_resources": {
"cpu_millis": 0,
"memory_bytes": 1,
"ephemeral_storage_bytes": 1,
}
},
"supervisor_resources.cpu_millis",
),
(
{
"supervisor_resources": {
"cpu_millis": 1,
"memory_bytes": 1,
}
},
"supervisor_resources.ephemeral_storage_bytes",
),
(
{
"supervisor_resources": {
"cpu_millis": 1,
"memory_bytes": 1,
"ephemeral_storage_bytes": 1,
"unknown": 1,
}
},
"unsupported key 'unknown'",
),
(
{
"planning_workers": {
"resources": {
"cpu_millis": 1,
"memory_bytes": 1,
"ephemeral_storage_bytes": 1,
},
"max_workers": 0,
"rows_per_worker": 1,
"fragments_per_worker": 1,
}
},
"planning_workers.max_workers",
),
(
{"max_executor_processes_per_worker": -2},
"max_executor_processes_per_worker",
+25
View File
@@ -6013,6 +6013,31 @@ def test_refresh_column_rejects_invalid_batch_size(tmp_path, method, batch_size)
{"resource_budget": {"cpu_millis": 1000, "memory_bytes": 1024}},
"resource_budget",
),
(
{
"supervisor_resources": {
"cpu_millis": 1000,
"memory_bytes": 1024,
"ephemeral_storage_bytes": 2048,
}
},
"supervisor_resources",
),
(
{
"planning_workers": {
"resources": {
"cpu_millis": 1000,
"memory_bytes": 1024,
"ephemeral_storage_bytes": 2048,
},
"max_workers": 2,
"rows_per_worker": 100,
"fragments_per_worker": 1,
}
},
"planning_workers",
),
({"num_workers": 2}, "num_workers"),
({"max_executor_processes_per_worker": 2}, "max_executor_processes_per_worker"),
],