mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-16 15:46:55 +00:00
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:
@@ -979,6 +979,42 @@ describe("remote connection", () => {
|
||||
},
|
||||
"resourceBudget.gpuCount",
|
||||
],
|
||||
[
|
||||
{
|
||||
supervisorResources: {
|
||||
cpuMillis: 0,
|
||||
memoryBytes: 1_024,
|
||||
ephemeralStorageBytes: 2_048,
|
||||
},
|
||||
},
|
||||
"supervisorResources.cpuMillis",
|
||||
],
|
||||
[
|
||||
{
|
||||
supervisorResources: {
|
||||
cpuMillis: 1_000,
|
||||
memoryBytes: 1_024,
|
||||
ephemeralStorageBytes: 0,
|
||||
},
|
||||
},
|
||||
"supervisorResources.ephemeralStorageBytes",
|
||||
],
|
||||
[
|
||||
{
|
||||
planningWorkers: {
|
||||
resources: {
|
||||
cpuMillis: 1_000,
|
||||
memoryBytes: 1_024,
|
||||
ephemeralStorageBytes: 2_048,
|
||||
},
|
||||
maxWorkers: 0,
|
||||
rowsPerWorker: 100,
|
||||
fragmentsPerWorker: 1,
|
||||
},
|
||||
},
|
||||
"planningWorkers.maxWorkers",
|
||||
],
|
||||
[{ retryPolicy: { maxAttempts: 0 } }, "retry_policy.max_attempts"],
|
||||
] as const) {
|
||||
await expect(
|
||||
table.refreshColumnAsync("embedding", options),
|
||||
@@ -1016,6 +1052,91 @@ describe("remote connection", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("forwards structured Function refresh options and Node retry policy", async () => {
|
||||
const bodies: unknown[] = [];
|
||||
await withMockDatabase(
|
||||
(req, res) => {
|
||||
const path = req.url ?? "";
|
||||
if (path.endsWith("/describe/")) {
|
||||
res.writeHead(200, { "Content-Type": "application/json" }).end(
|
||||
JSON.stringify({
|
||||
name: "docs",
|
||||
version: 1,
|
||||
schema: { fields: [] },
|
||||
}),
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (path === "/v1/table/docs/backfill_column") {
|
||||
let body = "";
|
||||
req.on("data", (chunk) => {
|
||||
body += chunk;
|
||||
});
|
||||
req.on("end", () => {
|
||||
bodies.push(JSON.parse(body));
|
||||
res
|
||||
.writeHead(202, { "Content-Type": "application/json" })
|
||||
.end('{"job_id": "j-structured"}');
|
||||
});
|
||||
return;
|
||||
}
|
||||
res.writeHead(404).end();
|
||||
},
|
||||
async (db) => {
|
||||
const table = await db.openTable("docs");
|
||||
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,
|
||||
},
|
||||
retryPolicy: { transient: true },
|
||||
});
|
||||
expect(job.id).toBe("j-structured");
|
||||
},
|
||||
);
|
||||
expect(bodies).toEqual([
|
||||
{
|
||||
column: "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,
|
||||
},
|
||||
["retry_policy"]: {
|
||||
["max_attempts"]: 3,
|
||||
["initial_backoff_seconds"]: 0.2,
|
||||
["max_backoff_seconds"]: 30,
|
||||
["exception_types"]: [],
|
||||
["message_pattern"]: null,
|
||||
["error_codes"]: [],
|
||||
transient: true,
|
||||
["honor_retry_after"]: true,
|
||||
},
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("surfaces JSON server errors from remote table operations", async () => {
|
||||
await withMockDatabase(
|
||||
(req, res) => {
|
||||
|
||||
@@ -5716,6 +5716,31 @@ describe("computed columns", () => {
|
||||
resourceBudget: { cpuMillis: 1_000, memoryBytes: 1_024 },
|
||||
}),
|
||||
).rejects.toThrow("resource_budget requires a LanceDB Enterprise refresh");
|
||||
await expect(
|
||||
table.refreshColumn("x", {
|
||||
supervisorResources: {
|
||||
cpuMillis: 1_000,
|
||||
memoryBytes: 1_024,
|
||||
ephemeralStorageBytes: 2_048,
|
||||
},
|
||||
}),
|
||||
).rejects.toThrow(
|
||||
"supervisor_resources requires a LanceDB Enterprise refresh",
|
||||
);
|
||||
await expect(
|
||||
table.refreshColumnAsync("x", {
|
||||
planningWorkers: {
|
||||
resources: {
|
||||
cpuMillis: 1_000,
|
||||
memoryBytes: 1_024,
|
||||
ephemeralStorageBytes: 2_048,
|
||||
},
|
||||
maxWorkers: 2,
|
||||
rowsPerWorker: 100,
|
||||
fragmentsPerWorker: 1,
|
||||
},
|
||||
}),
|
||||
).rejects.toThrow("planning_workers requires a LanceDB Enterprise refresh");
|
||||
});
|
||||
|
||||
it("records Function errors only on remote tables", async () => {
|
||||
|
||||
Reference in New Issue
Block a user