Skip to content

feat(python): accept the 0.9 names and deprecate the 0.8 spellings - #235

Merged
gouyt13 merged 3 commits into
mainfrom
feat/python-09-names
Nov 14, 2026
Merged

gouyt13 merged 3 commits into
mainfrom
feat/python-09-names

Conversation

@gouyt13

@gouyt13 gouyt13 commented Nov 14, 2026 •

Copy link
Copy Markdown
Member

Summary

0.9 gives the three index classes one name for each concept. This PR makes the next 0.8 release accept the 0.9 names next to the 0.8 spellings, and raise a DeprecationWarning for each 0.8 spelling at the caller's line, so code can move before 0.9 removes the old forms.

0.8 form (now warns) Name to use
IvfIndex.max_elements, SymqgIndex.max_elements num_stored_points
HnswIndex.max_elements, HnswIndex.resize(n) HnswIndex.capacity, HnswIndex.reserve(num_points) (grow-only)
IvfIndex.reserve(cluster_id, num_points) IvfIndex.reserve_cluster(cluster_id, num_points)
IvfIndex(initializer=...), index.initializer IvfIndex(routing=...), index.routing
search(queries, k, ef=...) on HnswIndex and SymqgIndex search(queries, k, ef_search=...)
high_accuracy or num_threads passed to search by position The keywords
nprobe=0, ef=0 for the default None, or omit the argument
HnswIndex(seed=s) with s above 2**32 - 1 A seed in [0, 2**32 - 1]

Changes

  • Python layer only. The extension keeps the 0.8 names. The new names are added in python_bindings/__init__.py, in one marked section next to the 0.8 compatibility layer, by replacing members on the classes. 0.9 deletes that section when the extension itself is renamed. No C++ file changes.
  • No 0.8 call changes. Results and exception types are the same as in 0.8.4. A malformed call is rejected before any deprecation warning, and passing an old and a new name together raises TypeError.
  • Not changed here. The HnswIndex default seed stays 100 and repr() keeps printing max_elements= and initializer=. 0.9 changes both without a warning, which the new release notes page announces.
  • Stubs. __init__.pyi declares the new members and the new search signatures, and marks each 0.8 form @deprecated. A deprecation that depends on a value (a breadth of 0, a large seed) cannot be declared and is documented in the docstrings.
  • Docs. The migration guide gets a "From 0.8 to 0.9" section and its 0.7-to-0.8 part stops recommending the deprecated forms. The index pages, the count properties in index/usage.md and the naming contract in docs/development.md use the new names. The samples and benchmarks/run.py use them too.
  • Release notes. docs/docs/releases/0.8.5.md is a new page, marked unreleased, for what is on main since 0.8.4. It also records feat(python): let IvfIndex.set_centroids take num_threads #231, which had no notes page.

Tests

  • New tests/python/test_compat_09.py (30 tests): each 0.8 form warns once, at the caller, and returns what the new form returns; each new form is silent; conflicting and malformed calls raise.
  • The tests were checked by mutation: forwarding a default breadth instead of ef_search, dropping num_threads, passing the wrong breadth in search_batch, and making the deprecated reserve a no-op each fail at least one test.
  • tests/test_mypy.py checks that mypy flags all 25 deprecated forms.
  • test_train_api.py, test_symqg_api.py and test_examples.py treat deprecation warnings as errors, so they move to the new names. The checks they lose (a breadth of 0, a seed above 32 bits) are covered in the new file.

About 170 uses of the 0.8 spellings remain in other tests. They pass and only warn; moving them is a follow-up, as #214 was for the 0.7 forms.

Checks

On Linux x86-64, Xeon Gold 6418H, GCC 14.3, Release, native optimization off; the package was built from this branch and installed.

  • Full Python suite with the mypy and Pyright tests: 1,167 passed, 18 skipped (16 need the C++ example targets, which were not built; 2 are wheel tests for other platforms).
  • The new file, the three migrated files and test_examples.py under -W error::DeprecationWarning: 156 passed.
  • The local environment is CPython 3.13. The first CI run failed one new test on CPython 3.11: a property added after class creation reported errors without its name before 3.13. The second commit fixes that (reproduced with 3.11 and 3.12 interpreters), and the suite passes again locally with it.
  • check-python.sh, mkdocs build --strict and git diff --check pass. No C++ source changes, so the C++ checks were not run locally.
  • Two independent reviews found no call that worked in 0.8.4 and breaks or changes its result: about 330 call forms were compared on 0.8.4 and on this branch, and import rabitqlib works under -O, -OO and -W error. Their findings (tests that could not detect a dropped argument, docs that still taught the old names, warnings raised before argument checks) are fixed here.

0.9 gives the three index classes one name for each concept (#232). This
release accepts both spellings and raises a DeprecationWarning, at the
caller's line, for the 0.8 one:

- HnswIndex.capacity and reserve(num_points) for max_elements and resize;
  max_elements is deprecated on IvfIndex and SymqgIndex.
- IvfIndex.reserve_cluster for reserve.
- IvfIndex(routing=...) and the routing property for initializer.
- search(queries, k, ef_search=...) for ef= on HnswIndex and SymqgIndex.
- Search options after the breadth are keyword-only; positions warn.
- nprobe=0 and ef_search=0 for the default warn; None selects it.
- HnswIndex seeds above 2**32 - 1 warn.

The extension keeps the 0.8 names, so the new ones are added in the Python
layer, which 0.9 deletes when the extension itself is renamed. No 0.8 call
changes its result or its exception type. The HnswIndex default seed and
repr() are unchanged here; the 0.9 changes to them are announced in the new
0.8.5 release notes page, which also records #231.
@github-actions github-actions Bot added the release:added Release category managed from the PR title label Nov 14, 2026
A property assigned to a class after its creation does not get
__set_name__, and before Python 3.13 it then reports errors without its
name: assigning to the read-only routing property raised "property of
'IvfIndex' object has no setter". CI's wheel tests on CPython 3.11 caught
this through test_new_members_are_named_after_their_class; the local
environment is 3.13, where the name falls back to the getter's name.

Call __set_name__ when adding the properties, so every supported Python
names them.
@gouyt13 gouyt13 self-assigned this Nov 14, 2026
@gouyt13
gouyt13 merged commit 2b5312b into main Nov 14, 2026
38 checks passed
@gouyt13
gouyt13 deleted the feat/python-09-names branch November 14, 2026 04:39
TamimEhsan pushed a commit to TamimEhsan/khorgosh that referenced this pull request Nov 20, 2026
Bump the version to 0.8.5 in pyproject.toml and CMakeLists.txt, and update
the install pins, clone commands and version text in the README, home
page, installation, quick start and C++ integration pages.

Turn docs/docs/releases/0.8.5.md into the release page: drop
"(unreleased)" from the title and the navigation, add the Upgrading
section, and correct three statements (search options become keyword-only
in 0.9, not now; set_centroids used every CPU for every routing type
before VectorDB-NTU#231; the stubs cannot mark the deprecations that depend on a value
or the two old statistics names).

The Python samples need 0.8.5 since VectorDB-NTU#235 and VectorDB-NTU#236, so their README asks
for it. README news gains v0.8.5 and keeps the three most recent entries.
TamimEhsan pushed a commit to TamimEhsan/khorgosh that referenced this pull request Nov 28, 2026
main is at v0.8.5 (cf2764f): the 0.9 names with deprecation warnings for
the 0.8 spellings (VectorDB-NTU#235, VectorDB-NTU#236) and the 0.8.5 release preparation (VectorDB-NTU#237).

Conflicts, resolved by keeping both sides:
- docs/docs/index/{hnsw,ivf,qg}.md: the cosine metric and the -1
  missing-result ID from dev/0.9, the new names from main.
- python_bindings/__init__.py: the FormatError import from dev/0.9 in
  main's import layout.
- python_bindings/__init__.pyi: cosine in the metric lists, routing for
  initializer.
- tests/python/typing/public_api.py: routing= with the cosine metric type.

Changes git could not make, because the two sides did not touch the same
lines:
- The deprecated search overloads from main return int64 IDs, as every
  search does on dev/0.9; a typing fixture checks it.
- The migration guide said three changes come without a warning in 0.9;
  with int64 IDs, the -1 marker and format 2 that count was wrong.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release:added Release category managed from the PR title

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant