mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 20:44:00 +00:00
fix!: preserve job attempt lineage, retries, and lifecycle states
BREAKING CHANGE: JobDescription, JobEventsRequest, FunctionErrorsRequest, and FunctionErrors gain optional Rust metadata/cursor fields. Existing struct literals must initialize them; use None when unavailable. Preserve typed attempt state, pinned retry lineage, result decoders and freshness fences, and retained diagnostic paging across SDKs. Keep Python job data access method-only.
This commit is contained in:
@@ -26,6 +26,20 @@ extra round trip on every call:
|
||||
|
||||
## Accessors
|
||||
|
||||
### attempt
|
||||
|
||||
```ts
|
||||
get attempt(): null | number
|
||||
```
|
||||
|
||||
One-based attempt ordinal. Worker replacement does not increment it.
|
||||
|
||||
#### Returns
|
||||
|
||||
`null` \| `number`
|
||||
|
||||
***
|
||||
|
||||
### creationMs
|
||||
|
||||
```ts
|
||||
@@ -40,6 +54,20 @@ When the job was created, in milliseconds since the epoch.
|
||||
|
||||
***
|
||||
|
||||
### executionEpoch
|
||||
|
||||
```ts
|
||||
get executionEpoch(): null | number
|
||||
```
|
||||
|
||||
Most recent execution's fencing token, when reported.
|
||||
|
||||
#### Returns
|
||||
|
||||
`null` \| `number`
|
||||
|
||||
***
|
||||
|
||||
### failure
|
||||
|
||||
```ts
|
||||
@@ -73,6 +101,23 @@ durable resume tokens.
|
||||
|
||||
***
|
||||
|
||||
### jobId
|
||||
|
||||
```ts
|
||||
get jobId(): null | string
|
||||
```
|
||||
|
||||
Identity of the selected attempt last observed by this handle.
|
||||
For operation handles, `refresh()` or `status()` can select a different
|
||||
attempt while `id` stays unchanged. Save this value after refreshing and
|
||||
use it throughout paged diagnostics. Local IDs cannot be reopened on a server.
|
||||
|
||||
#### Returns
|
||||
|
||||
`null` \| `string`
|
||||
|
||||
***
|
||||
|
||||
### jobType
|
||||
|
||||
```ts
|
||||
@@ -88,6 +133,34 @@ server-reported job type. Null for in-process handles.
|
||||
|
||||
***
|
||||
|
||||
### lifecycleState
|
||||
|
||||
```ts
|
||||
get lifecycleState(): null | JobState
|
||||
```
|
||||
|
||||
Detailed state last observed; unknown values never establish success.
|
||||
|
||||
#### Returns
|
||||
|
||||
`null` \| [`JobState`](../type-aliases/JobState.md)
|
||||
|
||||
***
|
||||
|
||||
### operationId
|
||||
|
||||
```ts
|
||||
get operationId(): null | string
|
||||
```
|
||||
|
||||
Root of the explicit retry lineage, when reported.
|
||||
|
||||
#### Returns
|
||||
|
||||
`null` \| `string`
|
||||
|
||||
***
|
||||
|
||||
### result
|
||||
|
||||
```ts
|
||||
@@ -104,6 +177,34 @@ instead.
|
||||
|
||||
***
|
||||
|
||||
### retryOf
|
||||
|
||||
```ts
|
||||
get retryOf(): null | string
|
||||
```
|
||||
|
||||
Immediate predecessor attempt, when reported.
|
||||
|
||||
#### Returns
|
||||
|
||||
`null` \| `string`
|
||||
|
||||
***
|
||||
|
||||
### sourceTableVersion
|
||||
|
||||
```ts
|
||||
get sourceTableVersion(): null | number
|
||||
```
|
||||
|
||||
Source snapshot pinned for this attempt, when reported.
|
||||
|
||||
#### Returns
|
||||
|
||||
`null` \| `number`
|
||||
|
||||
***
|
||||
|
||||
### spec
|
||||
|
||||
```ts
|
||||
@@ -175,6 +276,24 @@ per fragment. `filter` is a SQL-like expression over the `state`,
|
||||
|
||||
***
|
||||
|
||||
### history()
|
||||
|
||||
```ts
|
||||
history(options?): AsyncGenerator<Table<any>, any, unknown>
|
||||
```
|
||||
|
||||
Walk retained history one page at a time using the server's continuation.
|
||||
|
||||
#### Parameters
|
||||
|
||||
* **options?**: [`JobEventsOptions`](../interfaces/JobEventsOptions.md)
|
||||
|
||||
#### Returns
|
||||
|
||||
`AsyncGenerator`<`Table`<`any`>, `any`, `unknown`>
|
||||
|
||||
***
|
||||
|
||||
### progress()
|
||||
|
||||
```ts
|
||||
@@ -208,6 +327,20 @@ its full record, then cache it for the getters above.
|
||||
|
||||
***
|
||||
|
||||
### retry()
|
||||
|
||||
```ts
|
||||
retry(): Promise<Job<T>>
|
||||
```
|
||||
|
||||
Select this exact attempt's pinned successor. Requires backend support.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`Job`](Job.md)<`T`>>
|
||||
|
||||
***
|
||||
|
||||
### status()
|
||||
|
||||
```ts
|
||||
@@ -226,6 +359,20 @@ terminal failure state. Also refreshes the getters above.
|
||||
|
||||
***
|
||||
|
||||
### statusTyped()
|
||||
|
||||
```ts
|
||||
statusTyped(): Promise<JobState>
|
||||
```
|
||||
|
||||
Refresh and return the detailed lifecycle state.
|
||||
|
||||
#### Returns
|
||||
|
||||
`Promise`<[`JobState`](../type-aliases/JobState.md)>
|
||||
|
||||
***
|
||||
|
||||
### toString()
|
||||
|
||||
```ts
|
||||
|
||||
@@ -194,6 +194,7 @@
|
||||
- [IntoSql](type-aliases/IntoSql.md)
|
||||
- [IntoVector](type-aliases/IntoVector.md)
|
||||
- [JobProgressCallback](type-aliases/JobProgressCallback.md)
|
||||
- [JobState](type-aliases/JobState.md)
|
||||
- [MaterializedViewSelect](type-aliases/MaterializedViewSelect.md)
|
||||
- [MultiVector](type-aliases/MultiVector.md)
|
||||
- [QueryParameterValue](type-aliases/QueryParameterValue.md)
|
||||
|
||||
@@ -38,8 +38,8 @@ preview: CherryPickPreview;
|
||||
|
||||
```ts
|
||||
status:
|
||||
| "ready"
|
||||
| "failed"
|
||||
| "ready"
|
||||
| "notImplemented"
|
||||
| "cherryPicked"
|
||||
| "unknown";
|
||||
|
||||
@@ -22,11 +22,11 @@ optional activeJobId: string;
|
||||
|
||||
```ts
|
||||
optional blockedReason:
|
||||
| "cancelled"
|
||||
| "table_has_mem_wal"
|
||||
| "inputs_not_settled"
|
||||
| "dependency_in_flight"
|
||||
| "table_capacity"
|
||||
| "cancelled"
|
||||
| "preparation_backoff"
|
||||
| "failure_threshold_reached"
|
||||
| "binding_revision_missing";
|
||||
@@ -86,8 +86,8 @@ optional nextRunAtReason: string;
|
||||
|
||||
```ts
|
||||
state:
|
||||
| "running"
|
||||
| "queued"
|
||||
| "running"
|
||||
| "disabled"
|
||||
| "ready"
|
||||
| "up_to_date"
|
||||
|
||||
@@ -20,6 +20,16 @@ Fragments whose detail was capped.
|
||||
|
||||
***
|
||||
|
||||
### pageToken?
|
||||
|
||||
```ts
|
||||
optional pageToken: string;
|
||||
```
|
||||
|
||||
Continue the same job/filter. Absent for complete pages and older servers.
|
||||
|
||||
***
|
||||
|
||||
### records
|
||||
|
||||
```ts
|
||||
|
||||
@@ -37,3 +37,13 @@ optional limit: number;
|
||||
```
|
||||
|
||||
At most this many records (server default 10000, cap 100000).
|
||||
|
||||
***
|
||||
|
||||
### pageToken?
|
||||
|
||||
```ts
|
||||
optional pageToken: string;
|
||||
```
|
||||
|
||||
Empty starts retained history, including repaired rows, for an exact jobId; otherwise continue that page.
|
||||
|
||||
@@ -27,3 +27,13 @@ optional limit: number;
|
||||
```
|
||||
|
||||
Maximum event rows to return, up to the server maximum of 10,000.
|
||||
|
||||
***
|
||||
|
||||
### pageToken?
|
||||
|
||||
```ts
|
||||
optional pageToken: string;
|
||||
```
|
||||
|
||||
Opaque continuation from the preceding page's schema metadata.
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
[**@lancedb/lancedb**](../README.md) • **Docs**
|
||||
|
||||
***
|
||||
|
||||
[@lancedb/lancedb](../globals.md) / JobState
|
||||
|
||||
# Type Alias: JobState
|
||||
|
||||
```ts
|
||||
type JobState:
|
||||
| "created"
|
||||
| "queued"
|
||||
| "in_progress"
|
||||
| "succeeded"
|
||||
| "failed"
|
||||
| "canceled"
|
||||
| "timed_out"
|
||||
| string & object;
|
||||
```
|
||||
|
||||
Detailed lifecycle state. Unrecognized future values remain strings.
|
||||
@@ -452,6 +452,53 @@ identifiers. `fn.image` has a concise representation; `describe()` exposes Pytho
|
||||
and CUDA requirements without inspecting Pydantic internals. Platforms, base image
|
||||
and size are `None` until the service reports them. The full image descriptor and
|
||||
canonical JSON remain available.
|
||||
Jobs retain an attempt identity through `job_id()`, and explicit server retries
|
||||
report `operation_id()`, `attempt()`, and `retry_of()` when the server supports
|
||||
them.
|
||||
`lifecycle_state()` and `status_typed()` expose detailed `JobState` values while
|
||||
the existing string `status()` remains available. Unknown future states retain
|
||||
their value and never imply success. `source_table_version()` identifies the
|
||||
attempt's pinned input snapshot when reported.
|
||||
|
||||
```python
|
||||
from datetime import timedelta
|
||||
from lancedb import JobState
|
||||
|
||||
job = db.open_job(job_id)
|
||||
state = job.status_typed()
|
||||
if state is JobState.SUCCEEDED:
|
||||
print(job.operation_id(), job.attempt(), job.source_table_version())
|
||||
job.wait(timeout=timedelta(seconds=5))
|
||||
for page in job.history(limit=1000):
|
||||
print(page)
|
||||
```
|
||||
|
||||
A wait timeout leaves execution running and the handle reusable. Cancellation
|
||||
can be refused when publication has already acquired its commit claim; inspect
|
||||
the job again to learn that attempt's outcome. LanceDB Embedded handles have a
|
||||
stable identity for their lifetime and share typed lifecycle and wait semantics;
|
||||
their IDs cannot be reopened after a process restart. Event history, durable
|
||||
retries, and per-row Function errors require a backend that records them.
|
||||
|
||||
Explicit retries name the exact failed attempt and preserve its resolved
|
||||
Function version and source snapshot. Repeating `job.retry()` selects the same
|
||||
successor; call `retry()` on that successor to request another attempt. Safely
|
||||
retryable states and publication outcomes are validated by the backend.
|
||||
|
||||
```python
|
||||
retry = failed_job.retry()
|
||||
retry.refresh()
|
||||
attempt_job_id = retry.job_id()
|
||||
token = ""
|
||||
while token is not None:
|
||||
errors = table.function_errors(job_id=attempt_job_id, limit=1000, page_token=token)
|
||||
print(errors.records, errors.fragments)
|
||||
token = errors.page_token
|
||||
```
|
||||
|
||||
An empty error page can still carry a continuation. Keep the table, branch,
|
||||
job, and column filters unchanged while paging. Diagnose a terminal attempt for
|
||||
its complete retained row errors; an executing attempt is a partial observation.
|
||||
|
||||
A `@function` definition is also a local callable. Call a decorated function
|
||||
directly with row inputs, or call a decorated class with its initialization fields
|
||||
@@ -698,6 +745,8 @@ with BlobReader(read_range, len(payload)) as reader:
|
||||
|
||||
::: lancedb.job.Job
|
||||
|
||||
::: lancedb.job.JobState
|
||||
|
||||
::: lancedb.job.AsyncJob
|
||||
|
||||
::: lancedb.job.JobInfo
|
||||
|
||||
Reference in New Issue
Block a user