Repository navigation
feat: add list_running_requests and cancel_requests to MilvusClient - #3884
Conversation
|
This pull request is merged. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3884 +/- ##
==========================================
+ Coverage 94.82% 94.88% +0.06%
==========================================
Files 81 81
Lines 17421 17571 +150
==========================================
+ Hits 16519 16673 +154
+ Misses 902 898 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2164be7 to
cac5ef5
Compare
Expose the ListRunningRequests and CancelRequests RPCs (milvus-proto milvus-io#670, served by milvus #54276) on MilvusClient and AsyncMilvusClient. list_running_requests(db_name, collection_name, user, min_elapsed_ms) returns the Search / HybridSearch / Query requests the cluster is executing as RunningRequest rows; the filters are ANDed and a None filter is no constraint. The call succeeds as long as one proxy answered; a proxy that did not, or that predates the feature during a rolling upgrade, is logged as a warning since its requests are missing from the result. cancel_requests(request_ids, reason, user) cancels by the ids the list reported and returns a CancelRequestsResult that sorts every requested id into canceled, not_found or undetermined (a proxy did not answer), plus the per-proxy node results. An empty id list is rejected client side. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: czs007 <caozhenshan007@gmail.com>
Milvus now names a running request "<proxy id>-<proxy start>-<sequence>", e.g. "25-to03zu-rs", so request_id, request_ids, not_found and undetermined are strings in the proto (milvus-io/milvus-proto#696). Move the proto submodule to that commit and regenerate, make RunningRequest.request_id and the CancelRequestsResult id lists str, and accept only non-empty str ids in cancel_requests; the old numeric form raises ParamError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: czs007 <caozhenshan007@gmail.com>
cac5ef5 to
c8d38e7
Compare
|
Live check against a real cluster, run the same way for pymilvus (#3884), the Go SDK (milvus-io/milvus#55250) and the Java SDK (milvus-io/milvus-sdk-java#2180), on standalone instances built from milvus-io/milvus#54276 (merged). Data: 100,000 rows x 768 dims, FLAT. A slow search is nq 10,000.
pymilvus specifics:
Tested at c8d38e7. |
list_running_requests returned only the rows, so a caller could not tell a complete answer from one missing the requests of a proxy that did not answer; that was only logged. Return a ListRunningRequestsResult with requests and node_results instead, plus a complete property, matching cancel_requests and the Go and Java SDKs. The warning per unanswered proxy is still logged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: czs007 <caozhenshan007@gmail.com>
|
Follow-up to the comment above: |
- Remove five Parquet files that a local unit-test run wrote to bulk_writer/ and that were committed by mistake. - RunningRequest.to_dict delegates to dataclasses.asdict, so a new field cannot be left out of the dictionary. - The error-status tests of list_running_requests and cancel_requests now reach the mocked RPC (cancel_requests used to pass [1], which failed id validation first) and check that the server's code and reason reach the caller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: czs007 <caozhenshan007@gmail.com>
ListRunningRequestsResult.complete returned True when node_results was empty, because all() over an empty list is True. A current server sends one entry per proxy on every successful call, so an empty list means the server did not report per-proxy results and completeness cannot be confirmed. Return False in that case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: czs007 <caozhenshan007@gmail.com>
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: czs007, XuanYang-cn The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Expose the
ListRunningRequestsandCancelRequestsRPCs (milvus-io/milvus-proto#670 and #696, served by milvus-io/milvus#54276, merged) onMilvusClientandAsyncMilvusClient, so an operator can see which search / hybrid search / query requests the cluster is executing and stop one by id.Three commits:
list_running_requests(db_name=None, collection_name=None, user=None, min_elapsed_ms=0, timeout=None). Filters are ANDed;None/0is no constraint, sodb_name=Nonelists every database rather than the client's current one.cancel_requests(request_ids, reason="", user=None, timeout=None) -> CancelRequestsResultwithcanceled(the rows as they were when stopped),not_found,undetermined(a proxy did not answer, the id may still be running there) and the per-proxynode_results. An empty id list is rejected client side withParamError.AsyncMilvusClient."<proxy id>-<proxy start>-<sequence>"(enhance: make running-request ids opaque strings milvus-proto#696), sorequest_id,request_ids,not_foundandundeterminedarestr; the proto submodule moves to that commit and is regenerated.list_running_requestsreturnsListRunningRequestsResult(requests, node_results)with acompleteproperty, instead of only the rows. The call succeeds as long as one proxy answered, so withoutnode_resultsa caller could not tell a complete answer from one missing the requests of a proxy that did not answer (or that predates the feature during a rolling upgrade). This matchescancel_requestsand the Go (feat: add ListRunningRequests and CancelRequests to the Go SDK milvus#55250) and Java (feat: add listRunningRequests and cancelRequests to MilvusClientV2 milvus-sdk-java#2180) SDKs. A warning per unanswered proxy is still logged.New types
RunningRequest,RequestNodeResult,ListRunningRequestsResult,CancelRequestsResultinpymilvus.client.types, exported frompymilvus.Verification (head bd9f886):
ruff check pymilvus testsclean;tests/unit: 5728 passed, 1 skipped. Droppingnode_resultsfrom the list result makes 3 tests fail.node_results/completeinstead of the log. The string-id end-to-end check (gRPC, REST read through NodeJSON.parse,cause="cancel"metrics) passes 14/14.🤖 Generated with Claude Code