feat: cancel_job over REST (Database::cancel_job + remote impl + pyo3 + python)

Exposes the existing server-side CANCEL JOB (CoordinatorCatalog::cancel_job)
as a REST-backed SDK method: Database trait default NotSupported,
RemoteDatabase POSTs /v1/job/{id}/cancel, pyo3 binding, sync+async python
wrappers. Best-effort: a missing job returns false, not an error. Mock-HTTP
unit test in test_derived_compute_routes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Wyatt Alt
2026-06-13 07:09:45 -07:00
committed by Jack Ye
parent 04948fc4f6
commit 2b41fce033
5 changed files with 70 additions and 0 deletions

View File

@@ -658,6 +658,15 @@ class DBConnection(EnforceOverrides):
"""List inflight server-side jobs across the database's tables."""
return LOOP.run(self._conn.list_jobs())
def cancel_job(self, job_id: str) -> bool:
"""Cancel an inflight server-side job by id (CANCEL JOB).
Returns True if a matching inflight job was found and flagged for
cancellation, False if none was inflight (already finished or
unknown id) -- cancellation is best-effort.
"""
return LOOP.run(self._conn.cancel_job(job_id))
class LanceDBConnection(DBConnection):
"""
A connection to a LanceDB database.
@@ -1951,6 +1960,14 @@ class AsyncConnection(object):
"""List inflight server-side jobs across the database's tables."""
return await self._inner.list_jobs()
async def cancel_job(self, job_id: str) -> bool:
"""Cancel an inflight server-side job by id (CANCEL JOB).
Returns True if a matching inflight job was found and flagged for
cancellation, False otherwise (best-effort).
"""
return await self._inner.cancel_job(job_id)
async def rename_table(
self,
cur_name: str,

View File

@@ -510,6 +510,13 @@ impl Connection {
})
}
pub fn cancel_job(self_: PyRef<'_, Self>, job_id: String) -> PyResult<Bound<'_, PyAny>> {
let inner = self_.get_inner()?.clone();
future_into_py(self_.py(), async move {
inner.cancel_job(&job_id).await.infer_error()
})
}
#[pyo3(signature = (cur_name, new_name, cur_namespace_path=None, new_namespace_path=None))]
pub fn rename_table(
self_: PyRef<'_, Self>,