Skip to content

Add ClusteringInitMethod enum constants to __init__.pyi stub#5324

Open
alibeklfc wants to merge 1 commit into
facebookresearch:mainfrom
alibeklfc:export-D109007472
Open

Add ClusteringInitMethod enum constants to __init__.pyi stub#5324
alibeklfc wants to merge 1 commit into
facebookresearch:mainfrom
alibeklfc:export-D109007472

Conversation

@alibeklfc

Copy link
Copy Markdown
Contributor

Summary:
Add the three ClusteringInitMethod enum constants
(ClusteringInitMethod_RANDOM, ClusteringInitMethod_KMEANS_PLUS_PLUS,
ClusteringInitMethod_AFK_MC2) and the ClusteringInitMethod type alias to
the authoritative init.pyi Pyre stub.

These constants were introduced in commit bc5fe3d75e85 (Dec 2025) when
k-means++ and AFK-MC² centroid initialization were added to Clustering.h.
They are accessible at runtime via the SWIG-generated module but were never
added to init.pyi. When D107274305 (Jun 2026) wired init.pyi as
the authoritative Pyre source, all code using these constants acquired
[missing-attribute] errors. test_clustering_initialization.py already
references them 14 times.

Fix: add ClusteringInitMethod = int type alias and three int constants
near the MetricType block at the top of the stub (matching the established
pattern for SWIG-wrapped scoped enums). Update ClusteringParameters.init_method
from 'int # comment' to 'ClusteringInitMethod' to match how MetricType
is used throughout the file.

Test: buck test fbcode//faiss/tests:test_swig_wrapper — 25 pass, 0 fail
(24 pre-existing + 1 new: test_clustering_init_method_enum_values).
Test session: https://www.internalfb.com/intern/testinfra/testrun/32369622335973550

Reviewed By: limqiying

Differential Revision: D109007472

Summary:
Add the three ClusteringInitMethod enum constants
(ClusteringInitMethod_RANDOM, ClusteringInitMethod_KMEANS_PLUS_PLUS,
ClusteringInitMethod_AFK_MC2) and the ClusteringInitMethod type alias to
the authoritative __init__.pyi Pyre stub.

These constants were introduced in commit bc5fe3d75e85 (Dec 2025) when
k-means++ and AFK-MC² centroid initialization were added to Clustering.h.
They are accessible at runtime via the SWIG-generated module but were never
added to __init__.pyi. When D107274305 (Jun 2026) wired __init__.pyi as
the authoritative Pyre source, all code using these constants acquired
[missing-attribute] errors. test_clustering_initialization.py already
references them 14 times.

Fix: add ClusteringInitMethod = int type alias and three int constants
near the MetricType block at the top of the stub (matching the established
pattern for SWIG-wrapped scoped enums). Update ClusteringParameters.init_method
from 'int  # comment' to 'ClusteringInitMethod' to match how MetricType
is used throughout the file.

Test: buck test fbcode//faiss/tests:test_swig_wrapper — 25 pass, 0 fail
(24 pre-existing + 1 new: test_clustering_init_method_enum_values).
Test session: https://www.internalfb.com/intern/testinfra/testrun/32369622335973550

Reviewed By: limqiying

Differential Revision: D109007472
@meta-cla meta-cla Bot added the CLA Signed label Jun 18, 2026
@meta-codesync

meta-codesync Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

@alibeklfc has exported this pull request. If you are a Meta employee, you can view the originating Diff in D109007472.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant