mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
fix: expose Function metadata in SDK job listings (#5096)
Expose affected columns, pinned Function name/version, completion time,
duration and failure summaries on `JobInfo` in the Rust, Python and
TypeScript SDKs. Values come from the listing response, so callers can
inspect recent computed column refreshes without opening every job.
Older servers keep optional values absent; measured zero durations stay
zero.
```python
latest = next((info for info in db.list_jobs(table="events", job_type="function_refresh") if "embedding" in info.columns), None)
if latest is not None:
print(latest.function_name, latest.function_version, latest.duration_millis)
if latest.failure is not None:
print(latest.failure.message)
```
Duration is creation-to-completion wall time, including queueing and
pauses. Adds listing response coverage across SDKs and documents the
metadata contract, including SQL `SHOW JOBS EXTENDED` for the expanded
listing. Plain `SHOW JOBS` preserves its original columns. Local builds
and tests were skipped as requested.
The dependency advisory check also fails on current main because
`libsais-rs 0.2.0` is yanked ([main
job](https://github.com/lancedb/lancedb/actions/runs/44470513618/job/135378545456));
this PR does not change dependencies.
This changes the public shape of Rust and TypeScript `JobInfo`: callers
constructing summaries must supply the added fields (including
TypeScript `columns`). TypeScript table filtering remains a separate
concern; the guide now shows its client-side selection and namespace
limitation alongside Python and Rust server-side filters.
Refs ENT-3903.
This commit is contained in:
@@ -492,6 +492,18 @@ class JobInfo:
|
||||
@property
|
||||
def created_at_millis(self) -> int: ...
|
||||
@property
|
||||
def completed_at_millis(self) -> Optional[int]: ...
|
||||
@property
|
||||
def duration_millis(self) -> Optional[int]: ...
|
||||
@property
|
||||
def columns(self) -> list[str]: ...
|
||||
@property
|
||||
def function_name(self) -> Optional[str]: ...
|
||||
@property
|
||||
def function_version(self) -> Optional[str]: ...
|
||||
@property
|
||||
def failure(self) -> Optional[JobFailureInfo]: ...
|
||||
@property
|
||||
def progress(self) -> Optional[dict[str, Any]]: ...
|
||||
@property
|
||||
def paused(self) -> bool: ...
|
||||
|
||||
@@ -6984,10 +6984,29 @@ def test_remote_connection_jobs_surface():
|
||||
dict(
|
||||
job_id="job-2",
|
||||
table="t2",
|
||||
job_type="create_index",
|
||||
job_type="function_refresh",
|
||||
state="succeeded",
|
||||
created_at_millis=2000,
|
||||
)
|
||||
completed_at_millis=2000,
|
||||
duration_millis=0,
|
||||
columns=["embedding"],
|
||||
function_name="features$embed",
|
||||
function_version="7",
|
||||
),
|
||||
dict(
|
||||
job_id="job-3",
|
||||
table="t2",
|
||||
job_type="function_refresh",
|
||||
state="failed",
|
||||
created_at_millis=3000,
|
||||
completed_at_millis=3200,
|
||||
duration_millis=200,
|
||||
failure=dict(
|
||||
phase="execute",
|
||||
message="worker failed",
|
||||
retryable=False,
|
||||
),
|
||||
),
|
||||
]
|
||||
)
|
||||
request.send_response(200)
|
||||
@@ -7085,7 +7104,7 @@ def test_remote_connection_jobs_surface():
|
||||
|
||||
with mock_lancedb_connection(handler) as db:
|
||||
jobs = list(db.list_jobs())
|
||||
assert [job.job_id for job in jobs] == ["job-1", "job-2"]
|
||||
assert [job.job_id for job in jobs] == ["job-1", "job-2", "job-3"]
|
||||
assert jobs[0].state == "running"
|
||||
assert jobs[0].table == "t1"
|
||||
assert jobs[0].progress == {
|
||||
@@ -7099,6 +7118,24 @@ def test_remote_connection_jobs_surface():
|
||||
}
|
||||
assert jobs[0].paused is True
|
||||
assert jobs[1].state == "finished"
|
||||
assert jobs[0].completed_at_millis is None
|
||||
assert jobs[0].duration_millis is None
|
||||
assert jobs[0].columns == []
|
||||
assert jobs[0].function_name is None
|
||||
assert jobs[0].function_version is None
|
||||
assert jobs[0].failure is None
|
||||
assert jobs[1].completed_at_millis == 2000
|
||||
assert jobs[1].duration_millis == 0
|
||||
assert jobs[1].columns == ["embedding"]
|
||||
assert jobs[1].function_name == "features$embed"
|
||||
assert jobs[1].function_version == "7"
|
||||
assert jobs[1].failure is None
|
||||
assert jobs[2].state == "failed"
|
||||
assert jobs[2].duration_millis == 200
|
||||
assert jobs[2].failure.phase == "execute"
|
||||
assert jobs[2].failure.message == "worker failed"
|
||||
assert jobs[2].failure.retryable is False
|
||||
assert jobs[2].failure.traceback is None
|
||||
|
||||
assert db.cancel_job("job-1") is True
|
||||
assert db.cancel_job("missing") is False
|
||||
|
||||
@@ -254,6 +254,18 @@ pub struct JobInfo {
|
||||
job_type: String,
|
||||
state: String,
|
||||
created_at_millis: i64,
|
||||
/// Terminal timestamp in milliseconds since the epoch, when known.
|
||||
completed_at_millis: Option<i64>,
|
||||
/// Creation-to-completion wall time, including queueing and pauses.
|
||||
duration_millis: Option<i64>,
|
||||
/// Affected columns; empty when unavailable or not column-scoped.
|
||||
columns: Vec<String>,
|
||||
/// Pinned Function catalog name, with namespace segments joined by `$`.
|
||||
function_name: Option<String>,
|
||||
/// Pinned Function version, when known.
|
||||
function_version: Option<String>,
|
||||
/// Durable failure summary, when available.
|
||||
failure: Option<JobFailureInfo>,
|
||||
_progress_json: Option<String>,
|
||||
paused: bool,
|
||||
}
|
||||
@@ -290,6 +302,12 @@ impl From<lancedb::database::JobInfo> for JobInfo {
|
||||
job_type: info.job_type,
|
||||
state: info.state,
|
||||
created_at_millis: info.created_at_millis,
|
||||
completed_at_millis: info.completed_at_millis,
|
||||
duration_millis: info.duration_millis,
|
||||
columns: info.columns,
|
||||
function_name: info.function_name,
|
||||
function_version: info.function_version,
|
||||
failure: info.failure.map(Into::into),
|
||||
_progress_json: Some(progress),
|
||||
paused: info.paused,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user