Add Cluster Statistics (client.cluster.statistics())#1959
Conversation
There was a problem hiding this comment.
Orca Security Scan Summary
| Status | Check | Issues by priority | |
|---|---|---|---|
| Infrastructure as Code | View in Orca | ||
| SAST | View in Orca | ||
| Secrets | View in Orca | ||
| Vulnerabilities | View in Orca |
There was a problem hiding this comment.
Pull request overview
Adds a new cluster API to retrieve RAFT cluster statistics from the Weaviate server and exposes strongly-typed response models so users can easily consume and type-hint the returned data.
Changes:
- Add
client.cluster.statistics()implemented via_ClusterExecutor.statistics()callingGET /v1/cluster/statistics. - Introduce dataclass models for the cluster statistics response (
ClusterStatistics,NodeStatistics,RaftStats,RaftConfigurationMember). - Export new types + update sync/async
.pyistubs and add mock + integration tests for the new endpoint.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| weaviate/outputs/cluster.py | Exposes cluster-related output types (now includes statistics models). |
| weaviate/cluster/sync.pyi | Adds the typed sync stub for cluster.statistics(). |
| weaviate/cluster/async_.pyi | Adds the typed async stub for cluster.statistics(). |
| weaviate/cluster/models.py | Adds RAFT statistics dataclasses and decoding helpers. |
| weaviate/cluster/base.py | Implements _ClusterExecutor.statistics() using the connection executor. |
| mock_tests/test_collection.py | Adds a mock test validating request path and parsing into models. |
| integration/test_client.py | Adds an integration test validating basic response shape/fields. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1959 +/- ##
==========================================
+ Coverage 86.45% 86.55% +0.10%
==========================================
Files 274 276 +2
Lines 19966 20251 +285
==========================================
+ Hits 17261 17528 +267
- Misses 2705 2723 +18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
client.cluster.statistics().weaviate.cluster.models(ClusterStatistics,NodeStatistics,RaftStats,RaftConfigurationMember) to strongly type the full JSON response.weaviate.outputs.clusterso users can type‑hintClusterStatisticsand related models._ClusterExecutorand update.pyistubs for proper editor/type-checker support.Server Details
Weaviate Client Version: 4.19.5.dev2+g420b1d0b7.d20260220
Weaviate Server Version: 1.35.9
Local Example
Implementation Details
weaviate.cluster.base._ClusterExecutor.statistics()performs an authenticated HTTPGET /v1/cluster/statisticsthrough the existingConnection._decode_json_response_dictand converted into the new dataclasses, including nested RAFT configuration members.Testing
mock_tests/test_collection.py::test_cluster_statisticsverifies the request path and response parsing from a mocked/v1/cluster/statisticsendpoint.integration/test_client.py::test_client_cluster_statisticsexercisesclient.cluster.statistics()against a running Weaviate instance and asserts the basic shape/fields of the result.