mirror of
https://github.com/lancedb/lancedb.git
synced 2026-10-15 00:02:26 +00:00
Move the public website pages into `docs/web` beside the SDK, with
shared navigation and executable example sources in `docs/web-tests`.
The combined website is assembled by
[lancedb/docs#355](https://github.com/lancedb/docs/pull/355), with six
Enterprise replacements from
[lancedb/sophon#7681](https://github.com/lancedb/sophon/pull/7681).
This includes Function guidance, runnable Quickstarts, regenerated
snippets, production contact/demo fixes, the legacy SQL route, and the
LeRobot redirect. LeRobot remains attributed to Geneva; all 34 Geneva
pages remain in the docs repository until Function officially launches.
Materialized-view guidance follows the full rebuild refresh introduced
by #4373: local refresh writes the complete result, has no `full`
argument, supports `source_version`, and no longer requires stable row
IDs. Deployment SQL refresh options and stable-ID setup are qualified by
version/configuration. Function input guidance distinguishes ordinary
stored columns from computed inputs supported by newer deployments.
**Validation:** independently accepted local checks include 95 Python
tests (real Enterprise excluded), eight TypeScript tests, Rust
Quickstart, snippet parity, typos, deterministic assembly, Mint
validation and links/anchors/redirects. The combined baseline retains
all 181 production routes and 17 legacy redirects. Examples ran locally
against source-built Python SDK 0.40.0b13; existing GitHub workflows do
not run `docs/web-tests`. New main at `069b2f7d` is 0.41.0b0 and adds
computed Function inputs; that SDK was not exercised by the accepted
tests. Latest prose corrections receive focused site validation.
**Merge/rollout:** merge this and #7681 before #355's combined CI, which
reads producer `main`. This is migration infrastructure: section
overlays, source-owned skills and automatic versioned paired releases
remain follow-ups. The current manual publisher is transitional. Hosted
validation, a supported SDK/Enterprise release pair and a real
Enterprise walkthrough remain pending.
Production Mintlify watches `lancedb/docs:deploy-freeze`, directory
`docs`; preserve that source through review. The separate SDK GitHub
Pages reference workflow rebuilds on main merges.
**Updated-head CI (9a50f8db):**
[Typos](https://github.com/lancedb/lancedb/actions/runs/37654185443/job/112904990558),
[PR
title](https://github.com/lancedb/lancedb/actions/runs/37654179507/job/112904974595)
and
[Aikido](https://app.aikido.dev/featurebranch/scan/215386145?groupId=74229)
pass. Critical findings in the example lockfiles were patched: all Sharp
copies use 0.35.5, protobufjs 7.6.6, tar 7.5.22, quinn-proto 0.11.19,
zerovec 0.11.8 and zerovec-derive 0.11.6. The SDK's product dependencies
are unchanged. The revised lockfiles pass eight TypeScript examples,
HuggingFace decode/resize/crop/rescale/normalize plus AVIF roundtrip,
and Rust Quickstart. Aikido passing does not mean every advisory is
cleared; npm still reports 29 high and five moderate advisories in the
example dependency graph. No scanner bypass or suppression was added.
The Function prose correction passes combined/standalone Mint,
deterministic assembly, routes and assets. The revised 325-file site
checksum is
`175bec06864abb400dd292e667ba93448c0479b8359fd7bf6146afabf9040647`. This
PR remains open for independent review; further merges are on hold.
---------
Co-authored-by: Brendan Clement <brendan.clement@lancedb.com>
197 lines
6.5 KiB
Plaintext
197 lines
6.5 KiB
Plaintext
---
|
|
title: "Jobs"
|
|
sidebarTitle: "Job"
|
|
description: "Work that outlives the call that started it: submitting, waiting, inspecting, cancelling."
|
|
icon: hourglass-half
|
|
keywords: ["job", "async", "background", "events", "cancel", "refresh"]
|
|
---
|
|
|
|
Some operations take longer than a request should. Building an index over a
|
|
large table, refreshing a computed column, registering a function -- these run
|
|
on the server after the call that started them has returned.
|
|
|
|
Each is submitted the same way and returns the same handle.
|
|
|
|
<Note>
|
|
A [query](/basics/query) also has an `_async` form, but its handle streams rows
|
|
rather than waiting for an outcome. Both answer the same four questions --
|
|
which one is this, how is it going, give me the result, stop it -- and differ
|
|
only in the third.
|
|
</Note>
|
|
|
|
## The `_async` convention {#convention}
|
|
|
|
An operation that can run in the background has two forms. The plain name blocks
|
|
until the work is done. The `_async` / `Async` name submits the work and returns
|
|
a **job** immediately.
|
|
|
|
| Blocking | Returns a job | SQL |
|
|
| --- | --- | --- |
|
|
| `create_index` | `create_index_async` | `CREATE INDEX` |
|
|
| `refresh_column` | `refresh_column_async` | `REFRESH COLUMN` |
|
|
| `create_function` | `create_function_async` | `CREATE FUNCTION` |
|
|
| `drop_table` | `drop_table_async` | `DROP TABLE` |
|
|
|
|
<Note>
|
|
The blocking form is not a different operation -- it submits the same job and
|
|
waits. Reach for the `_async` form when you want to do something else meanwhile,
|
|
run several at once, or survive the client going away.
|
|
</Note>
|
|
|
|
## Submitting and waiting {#waiting}
|
|
|
|
<CodeGroup>
|
|
```python Python icon="python"
|
|
from lancedb.index import IvfPq
|
|
|
|
job = table.create_index_async("vector", config=IvfPq())
|
|
|
|
print(job.id) # the server's id for this operation
|
|
print(job.status()) # "running" | "finished" | "failed" | "cancelled"
|
|
|
|
job.wait() # blocks until terminal; raises if it failed
|
|
```
|
|
|
|
```typescript TypeScript icon="square-js"
|
|
const job = await table.createIndexAsync("vector");
|
|
|
|
console.log(job.id); // the server's id for this operation
|
|
console.log(await job.status()); // "running" | "finished" | "failed" | "cancelled"
|
|
|
|
await job.wait(); // resolves when terminal; rejects if it failed
|
|
```
|
|
</CodeGroup>
|
|
|
|
`wait` is the one call that raises on failure. `status` is a point snapshot and
|
|
returns the failed state rather than raising, which is what you want in a
|
|
polling loop.
|
|
|
|
In Python `wait` takes an optional timeout and returns the operation's typed
|
|
result -- a `RefreshColumnJobResult`, a `FunctionVersion`, or `None` for an
|
|
operation that has no result:
|
|
|
|
```python
|
|
from datetime import timedelta
|
|
|
|
result = table.refresh_column_async("embedding").wait(timeout=timedelta(minutes=30))
|
|
```
|
|
|
|
`TimeoutError` means the timeout elapsed, not that the job stopped. The job is
|
|
still running; the handle just gave up watching.
|
|
|
|
<Note>
|
|
The TypeScript `wait()` resolves to `void`. Read the outcome from `result` after
|
|
it resolves.
|
|
</Note>
|
|
|
|
## Inspecting a job {#inspecting}
|
|
|
|
Submitting an operation returns only an id, so the detail fields are empty until
|
|
the handle fetches the record. `refresh()` does that; `status()` does it as a
|
|
side effect.
|
|
|
|
<CodeGroup>
|
|
```python Python icon="python"
|
|
job.refresh()
|
|
|
|
job.state # last observed state, without another round trip
|
|
job.job_type # what kind of job, as the server names it
|
|
job.creation_ms # when it was created, epoch milliseconds
|
|
job.spec # what it was submitted with
|
|
job.result # its terminal result, once it succeeds
|
|
job.failure # why it failed, when it did
|
|
```
|
|
|
|
```typescript TypeScript icon="square-js"
|
|
await job.refresh();
|
|
|
|
job.state; // last observed state, without another round trip
|
|
job.jobType; // what kind of job, as the server names it
|
|
job.creationMs; // when it was created, epoch milliseconds
|
|
job.spec; // what it was submitted with
|
|
job.result; // its terminal result, once it succeeds
|
|
job.failure; // why it failed, when it did
|
|
```
|
|
</CodeGroup>
|
|
|
|
Printing the handle renders every field it knows, which is usually faster than
|
|
reading them one at a time.
|
|
|
|
## Progress, from events {#events}
|
|
|
|
`result` only tells you anything once the job has finished. Events are written
|
|
as it runs, and they outlive the workers that produced them -- so a job that is
|
|
still going, or one that never finished, can still account for what it did.
|
|
|
|
<CodeGroup>
|
|
```python Python icon="python"
|
|
events = job.events(limit=5000, filter="state = 'claim_complete'")
|
|
```
|
|
|
|
```typescript TypeScript icon="square-js"
|
|
const events = await job.events({ limit: 5000, filter: "state = 'claim_complete'" });
|
|
```
|
|
|
|
```sql SQL
|
|
SHOW ERRORS ON my_table FOR JOB 'job-id' LIMIT 100
|
|
```
|
|
</CodeGroup>
|
|
|
|
A distributed job records a `claim` / `claim_complete` pair per unit of work,
|
|
each carrying `rows_processed`. Summing `rows_processed` over the completed
|
|
claims is how you get progress on a job that has no percentage.
|
|
|
|
`filter` is a SQL-like expression over `state`, `updated_by`, `emitted_from`,
|
|
`emitted_by`, and `claim_entity`.
|
|
|
|
<Warning>
|
|
The server returns 1000 event rows by default and 10,000 at most, and
|
|
**truncates without telling you**. A job that emits an event per fragment will
|
|
silently lose its tail unless you pass `limit`.
|
|
</Warning>
|
|
|
|
Events are recorded server-side, so this raises for an operation that ran
|
|
in-process.
|
|
|
|
## Finding and cancelling jobs {#managing}
|
|
|
|
The connection lists and reopens jobs, so a handle lost to a restarted process
|
|
is recoverable from its id.
|
|
|
|
<CodeGroup>
|
|
```python Python icon="python"
|
|
db.list_jobs() # every job the server knows about
|
|
job = db.open_job(job_id) # reattach to one
|
|
db.cancel_job(job_id) # ask it to stop
|
|
```
|
|
|
|
```typescript TypeScript icon="square-js"
|
|
await db.listJobs();
|
|
const job = await db.openJob(jobId);
|
|
await db.cancelJob(jobId);
|
|
```
|
|
|
|
```sql SQL
|
|
SHOW JOBS
|
|
```
|
|
</CodeGroup>
|
|
|
|
Cancellation is a request, not a guarantee, and cancelling a job that already
|
|
finished does nothing. `JobNotFoundError` means the id does not name a job the
|
|
server still has.
|
|
|
|
<Warning>
|
|
A job id is opaque. It correlates with server logs and the calls above, but
|
|
parsing it or storing it to resume the job later is not supported.
|
|
</Warning>
|
|
|
|
## In-process jobs {#in-process}
|
|
|
|
A local database has no server to run anything, so its operations run in your
|
|
process. They still return a handle, so the same code works against both -- but
|
|
one with nothing behind it: `id` is `None`, `status()` reports `"finished"`,
|
|
`wait()` returns immediately, `cancel()` does nothing, and `events()` raises.
|
|
|
|
This is the difference to expect when moving between embedded and deployed --
|
|
see [SDKs](/basics/sdk).
|