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
+8 -2
View File
@@ -1225,12 +1225,18 @@ LanceDB Enterprise it is the server's backfill job.
`REFRESH COLUMN ... WHERE ... WITH (...)` form: `where` narrows the rows,
`errorPolicy`, `maxFailedFraction`, `maxFailedRows`, `rowTimeoutSeconds`
and `initTimeoutSeconds` govern failing rows. `batchSize`, `gpuClass`,
`maxConcurrency`, `resourceBudget` and
`maxExecutorProcessesPerWorker` size registered Function refreshes.
`maxConcurrency`, `resourceBudget`, `supervisorResources`,
`planningWorkers` and `maxExecutorProcessesPerWorker` size registered
Function refreshes. `retryPolicy` overrides user-code retries only when
repeating partial work is safe; set `maxAttempts: 1` to disable retries.
`maxConcurrency` overrides the registered default for this logical
execution only and is a positive integer; it is not an account-wide
quota. A `resourceBudget` requires `cpuMillis` and
`memoryBytes`; its `gpuCount` defaults to zero for a CPU-only Function.
`supervisorResources` and each `planningWorkers.resources` entry require
positive `cpuMillis`, `memoryBytes` and `ephemeralStorageBytes`.
`planningWorkers` also requires positive `maxWorkers`,
`rowsPerWorker` and `fragmentsPerWorker`.
The budget applies only to this explicit refresh and does not configure
a later automatic refresh.
`gpuCount` at the top level is the shorthand that preserves the
+3
View File
@@ -103,6 +103,9 @@
- [FunctionErrorRecord](interfaces/FunctionErrorRecord.md)
- [FunctionErrors](interfaces/FunctionErrors.md)
- [FunctionErrorsOptions](interfaces/FunctionErrorsOptions.md)
- [FunctionRefreshPlanningConfig](interfaces/FunctionRefreshPlanningConfig.md)
- [FunctionRefreshPodResources](interfaces/FunctionRefreshPodResources.md)
- [FunctionRetryPolicy](interfaces/FunctionRetryPolicy.md)
- [FunctionWorkerResourceBudget](interfaces/FunctionWorkerResourceBudget.md)
- [HnswPqOptions](interfaces/HnswPqOptions.md)
- [HnswSqOptions](interfaces/HnswSqOptions.md)
@@ -0,0 +1,50 @@
[**@lancedb/lancedb**](../README.md) • **Docs**
***
[@lancedb/lancedb](../globals.md) / FunctionRefreshPlanningConfig
# Interface: FunctionRefreshPlanningConfig
Resources and sizing policy for the planning fleet of one registered
Function refresh.
## Properties
### fragmentsPerWorker
```ts
fragmentsPerWorker: number;
```
Maximum fragments assigned to one planning worker.
***
### maxWorkers
```ts
maxWorkers: number;
```
Maximum number of planning workers.
***
### resources
```ts
resources: FunctionRefreshPodResources;
```
CPU, memory, and ephemeral-storage limits for one planning worker.
***
### rowsPerWorker
```ts
rowsPerWorker: number;
```
Maximum rows assigned to one planning worker.
@@ -0,0 +1,40 @@
[**@lancedb/lancedb**](../README.md) • **Docs**
***
[@lancedb/lancedb](../globals.md) / FunctionRefreshPodResources
# Interface: FunctionRefreshPodResources
CPU, memory, and ephemeral-storage limits for one Function refresh
control-plane pod.
## Properties
### cpuMillis
```ts
cpuMillis: number;
```
CPU limit in millicores; 1000 is one CPU.
***
### ephemeralStorageBytes
```ts
ephemeralStorageBytes: number;
```
Ephemeral storage limit in bytes.
***
### memoryBytes
```ts
memoryBytes: number;
```
Memory limit in bytes.
@@ -0,0 +1,91 @@
[**@lancedb/lancedb**](../README.md) • **Docs**
***
[@lancedb/lancedb](../globals.md) / FunctionRetryPolicy
# Interface: FunctionRetryPolicy
Overrides retries of failed user-code calls for one refresh. Omitted
fields use the Function refresh defaults.
## Properties
### errorCodes?
```ts
optional errorCodes: string[];
```
Structured provider error codes or HTTP status codes.
***
### exceptionTypes?
```ts
optional exceptionTypes: string[];
```
Exception class names, preferably qualified.
***
### honorRetryAfter?
```ts
optional honorRetryAfter: boolean;
```
Honor Retry-After within the configured maximum.
***
### initialBackoffSeconds?
```ts
optional initialBackoffSeconds: number;
```
Initial exponential-backoff ceiling, in seconds.
***
### maxAttempts?
```ts
optional maxAttempts: number;
```
Total calls, including the first; 1 disables retries, maximum 100.
***
### maxBackoffSeconds?
```ts
optional maxBackoffSeconds: number;
```
Maximum backoff, in seconds.
***
### messagePattern?
```ts
optional messagePattern: string;
```
Regular expression matched against the exception class and message.
***
### transient?
```ts
optional transient: boolean;
```
Match connection/timeouts, HTTP 429/503, SlowDown and
ServiceUnavailable.
@@ -117,6 +117,16 @@ Worker count for an expression column; Function columns reject it.
***
### planningWorkers?
```ts
optional planningWorkers: FunctionRefreshPlanningConfig;
```
Resources and sizing for the refresh planning fleet.
***
### publicationIntervalRows?
```ts
@@ -141,6 +151,16 @@ refresh. `gpuCount` inside the budget defaults to zero.
***
### retryPolicy?
```ts
optional retryPolicy: FunctionRetryPolicy;
```
Override retries of failed user-code calls for this refresh.
***
### rowTimeoutSeconds?
```ts
@@ -151,6 +171,16 @@ Deadline for one Function call, in seconds.
***
### supervisorResources?
```ts
optional supervisorResources: FunctionRefreshPodResources;
```
CPU, memory, and ephemeral-storage limits for the refresh supervisor.
***
### where?
```ts
@@ -400,6 +400,101 @@ for changing only the aggregate GPU budget. It cannot be combined with the
complete resource budget. Omitting both preserves the server's existing
defaults.
{/*
Draft for the Function refresh control-plane resource release.
`resource_budget` above sizes the Function workers. Two independent options
size the refresh control plane for a registered Function.
`supervisor_resources` sets the CPU, memory and ephemeral-storage limits of
the supervisor pod. `planning_workers` sets the resources of one planning
worker and the sizing of the CPU-only planning fleet: `max_workers`,
`rows_per_worker` and `fragments_per_worker`. Every field is required and
must be positive. Omitting either option leaves the server's configured
defaults unchanged, and either can be combined with `resource_budget`.
<CodeGroup>
```python Python icon="python"
job = table.refresh_column_async(
"embedding",
supervisor_resources={
"cpu_millis": 2_000,
"memory_bytes": 4 * 1024**3,
"ephemeral_storage_bytes": 10 * 1024**3,
},
planning_workers={
"resources": {
"cpu_millis": 1_000,
"memory_bytes": 2 * 1024**3,
"ephemeral_storage_bytes": 5 * 1024**3,
},
"max_workers": 4,
"rows_per_worker": 100_000,
"fragments_per_worker": 8,
},
)
job.wait()
```
```rust Rust icon="rust"
use lancedb::table::{
FunctionRefreshPlanningConfig,
FunctionRefreshPodResources,
RefreshColumnOptions,
};
let _job = table
.refresh_column_async_with_options(
"embedding",
RefreshColumnOptions::default()
.supervisor_resources(
FunctionRefreshPodResources::new(
2_000,
4 * 1024 * 1024 * 1024,
10 * 1024 * 1024 * 1024,
),
)
.planning_workers(
FunctionRefreshPlanningConfig::new(
FunctionRefreshPodResources::new(
1_000,
2 * 1024 * 1024 * 1024,
5 * 1024 * 1024 * 1024,
),
4,
100_000,
8,
),
),
)
.await?;
```
```typescript TypeScript icon="typescript"
const job = await table.refreshColumnAsync("embedding", {
supervisorResources: {
cpuMillis: 2_000,
memoryBytes: 4 * 1024 ** 3,
ephemeralStorageBytes: 10 * 1024 ** 3,
},
planningWorkers: {
resources: {
cpuMillis: 1_000,
memoryBytes: 2 * 1024 ** 3,
ephemeralStorageBytes: 5 * 1024 ** 3,
},
maxWorkers: 4,
rowsPerWorker: 100_000,
fragmentsPerWorker: 8,
},
});
await job.wait();
```
</CodeGroup>
The SDK validates the shape and sends these values only with this explicit
refresh request. A supporting LanceDB Enterprise server is required.
*/}
These examples configure only the explicit refresh shown. A registered
Function declaration can separately set `auto_refresh_resource_budget` on
`add_columns`; that declaration controls the budget for its automatic
@@ -457,6 +552,39 @@ from `lancedb.functions`. Use `FunctionRetryPolicy(max_attempts=1)` to
disable user-error retries. Omitting the override preserves the registered
policy.
<CodeGroup>
```python Python icon="python"
from lancedb.functions import FunctionRetryPolicy
job = table.refresh_column_async(
"embedding",
retry_policy=FunctionRetryPolicy(transient=True, max_attempts=3),
)
job.wait()
```
```rust Rust icon="rust"
use lancedb::{function::FunctionRetryPolicy, table::RefreshColumnOptions};
let mut retry_policy = FunctionRetryPolicy::transient();
retry_policy.max_attempts = 3;
let _job = table
.refresh_column_async_with_options(
"embedding",
RefreshColumnOptions::default().retry_policy(retry_policy),
)
.await?;
```
```typescript TypeScript icon="typescript"
const job = await table.refreshColumnAsync("embedding", {
retryPolicy: { transient: true, maxAttempts: 3 },
});
await job.wait();
```
</CodeGroup>
This requires a supporting LanceDB Enterprise server as well as an SDK
that exposes these options. An older Function image may need
re-registration before it accepts a refresh override. Only enable retries