Add client support for replication scale plans (GET/POST /v1/replication/scale)

Đang mở
#2,259 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
48/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
api, backend

Hướng nghiên cứu

Read the existing client.cluster.replications methods (get, query and cancel), related models in weaviate.cluster.models, and the client’s version checks and stub generation workflow. Implement sync and async methods for retrieving and applying scale plans, with typed models, validation, and server version handling. Add unit, mock, and integration coverage; done means the scale plan can be retrieved and applied against a supported server, with the requested error and validation cases covered.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Summary

Weaviate has offered GET and POST /v1/replication/scale since v1.35. They compute and apply a plan to change a collection's replication factor. The Python client has no methods for them, so changing a collection's replication factor from Python means making raw REST calls and building the plan payload by hand.

Proposal

Add two methods to the existing client.cluster.replications namespace, next to get, query and cancel, for both the sync and async clients:

plan = client.cluster.replications.get_scale_plan(collection="Article", replication_factor=3)
# inspect plan.shard_scale_actions -> {shard: ShardScaleActions(remove_nodes=[...], add_nodes={target: source | None})}
result = client.cluster.replications.apply_scale_plan(plan=plan)
# result.operation_ids -> the started shard copy operations, trackable with replications.get(uuid=...)
  • New typed models in weaviate.cluster.models: ReplicationScalePlan, ShardScaleActions and ReplicationScaleApplyResult. They are exported from weaviate.outputs.replication.
  • A version check raises WeaviateUnsupportedFeatureError on servers older than 1.35, the same way tokenization and export do.
  • replication_factor is validated on the client (it must be an integer of at least 1), and the collection name's first letter is capitalised, as elsewhere in the client.
  • Additive only: no changes to existing signatures, overloads or dependencies. The stubs are regenerated with tools/stubs_regen.sh.
Validation done locally

I have a working implementation, tested against a local 3-node 1.40.5 cluster with REPLICA_MOVEMENT_ENABLED=true:

  • Scaling a 2-shard collection from 1 to 3 replicas started 4 copy operations, all of which reached READY, and all objects stayed readable.
  • Scaling back down produced a removal-only plan, applied with no copy operations.
  • Added unit and mock tests (sync and async, plan round-trip, invalid factor, old-server error) and an integration test in integration/test_replicate.py.
  • ruff, pyright 1.1.399 and the flake8 pre-commit hooks pass.

Would you accept a PR for this? I'm happy to adjust the method names or where they live, for example on client.cluster next to replicate() instead.

Ngôn ngữ chính
Python
Star
230
Fork
173
Merge trung bình
4 ngày 16 giờ
Pull request đã merge (30 ngày)
23

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của weaviate/weaviate-python-client

Tất cả issue của weaviate/weaviate-python-client

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.