Skip to content

feat(batch): expose server deletion cap as DeleteManyReturn.limit - #2273

Open
suryakvk wants to merge 2 commits into
weaviate:mainfrom
suryakvk:feat/delete-many-limit
Open

suryakvk wants to merge 2 commits into
weaviate:mainfrom
suryakvk:feat/delete-many-limit

Conversation

@suryakvk

Copy link
Copy Markdown

Summary

Weaviate 1.39+ exposes the per-call batch-delete cap (QUERY_MAXIMUM_RESULTS) as optional int64 limit = 6 on gRPC BatchDeleteReply. This PR regenerates the versioned batch_delete protobuf stubs and surfaces the field on DeleteManyReturn.limit so callers can tell when a delete_many() call was capped (matches > limit) without hardcoding server configuration.

Changes

  • Protobuf stubs (v4216, v5261, v6300): Regenerated via weaviate/proto/v1/regen.sh against Weaviate v1.40.7, adding BatchDeleteReply.limit.
  • weaviate/collections/classes/batch.py: Added limit: Optional[int] = None to DeleteManyReturn (additive and backward-compatible with existing positional/keyword callers and @overload annotations).
  • weaviate/collections/batch/grpc_batch_delete.py: Populated limit = res.limit if res.HasField("limit") else None for both verbose=True and verbose=False (shared across sync and async clients; preserves explicit 0 and returns None on servers < 1.39).
  • Tests:
    • mock_tests/test_batch_delete.py: Sync and async mock gRPC coverage for capped (matches=8, successful=5, limit=5), uncapped (matches=3, successful=3, limit=5), explicit zero (limit=0), and omitted (limit=None) replies across verbose=False/True.
    • integration/test_collection_batch_delete.py: Added test_delete_many_limit across verbose and dry_run combinations, version-gated for Weaviate < 1.39 vs >= 1.39.

Validation

  • Live test against Weaviate 1.40.7 with QUERY_MAXIMUM_RESULTS=5 (sync + async): confirmed capped (matches=6, successful=5, limit=5), exact boundary (matches=5, successful=5, limit=5), uncapped (matches=3, successful=3, limit=5), verbose=True, and dry_run=True
  • pytest integration/test_collection_batch_delete.py -k test_delete_many_limit against live Weaviate 1.40.7 (4 passed)
  • pytest proto_test/test_proto.py mock_tests/test_batch_delete.py (15 passed)
  • pytest test (619 passed, 1 skipped) and pytest mock_tests (110 passed)
  • ruff check & ruff format --diff (clean)
  • pyright on weaviate/ and integration/ (0 errors)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

@orca-security-eu orca-security-eu Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed SAST high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Vulnerabilities high 0   medium 0   low 0   info 0 View in Orca

@weaviate-git-bot

Copy link
Copy Markdown

To avoid any confusion in the future about your contribution to Weaviate, we work with a Contributor License Agreement. If you agree, you can simply add a comment to this PR that you agree with the CLA so that we can merge.

beep boop - the Weaviate bot 👋🤖

PS:
Are you already a member of the Weaviate Forum?

@suryakvk

Copy link
Copy Markdown
Author

I agree to the Contributor License Agreement

@chrikrah chrikrah left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mock tests pin limit through both paths, and they fail without the two production files. Ready to go in from my side.

# exported tree of a5562401, Python 3.12, weaviate imported from the tree
$ pytest -q mock_tests/test_batch_delete.py
11 passed
# grpc_batch_delete.py and classes/batch.py from base 0e821a53, stubs and tests kept
11 failed
$ pytest -q -n 4 test && pytest -q mock_tests && pytest -q proto_test/test_proto.py
619 passed, 1 skipped / 110 passed / 4 passed
$ pre-commit run --all-files   # ruff, ruff format, flake8: no finding in changed files
# not run: integration/ (needs a live Weaviate)

non-blocking: the field first ships in v1.39.7 (batch_delete.proto at v1.39.6 has no limit = 6), and by my reading test_delete_many_limit would fail against 1.39.0 to 1.39.6. CI pins 1.39.13. Could you move the gate to is_lower_than(1, 39, 7) and the docstring to "< 1.39.7"?

…ng to 1.39.7

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@suryakvk

Copy link
Copy Markdown
Author

Thanks for the review and for catching the exact version @chrikrah! Updated both the integration version gate (is_lower_than(1, 39, 7)) and the DeleteManyReturn.limit docstring (< 1.39.7) in dd07c14.

@chrikrah chrikrah left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dd07c14 moves both the integration gate and the docstring to 1.39.7, which is the first server that sends limit, and nothing else changed. Still good to go from my side.

# exported tree of dd07c147 (previous head a5562401), Python 3.12, weaviate.__file__ from the export
$ pytest -q mock_tests/test_batch_delete.py
11 passed
$ git diff a5562401 dd07c147 --stat
integration/test_collection_batch_delete.py | 2 +-
weaviate/collections/classes/batch.py       | 2 +-
# not run: integration/ (needs a live Weaviate at 1.39.0 to 1.39.6 to hit the new branch)

Nothing more from me here; it now needs a maintainer.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants