diff --git a/test/collection/test_config.py b/test/collection/test_config.py index 360a0d138..d793d1487 100644 --- a/test/collection/test_config.py +++ b/test/collection/test_config.py @@ -1,3 +1,4 @@ +import warnings from typing import List, Union import pytest @@ -874,6 +875,45 @@ def test_config_with_vectorizer_and_properties( } +def test_config_with_vector_config_warns_on_skip_vectorization() -> None: + """With `vector_config` the flag is not sent, so setting it must warn (Dep032).""" + config = _CollectionConfigCreate( + name="test", + properties=[Property(name="text", data_type=DataType.TEXT, skip_vectorization=True)], + vector_config=Configure.Vectors.text2vec_transformers(), + ) + with pytest.warns(DeprecationWarning, match="Dep032"): + config._to_dict() + + +@pytest.mark.parametrize( + "kwargs", + [ + # flag not set at all + { + "properties": [Property(name="text", data_type=DataType.TEXT)], + "vector_config": Configure.Vectors.text2vec_transformers(), + }, + # legacy path maps the flag, so it does take effect + { + "properties": [Property(name="text", data_type=DataType.TEXT, skip_vectorization=True)], + "vectorizer_config": Configure.Vectorizer.text2vec_transformers(), + }, + # nothing is vectorized, so the flag is moot + { + "properties": [Property(name="text", data_type=DataType.TEXT, skip_vectorization=True)], + "vector_config": Configure.Vectors.self_provided(), + }, + {"properties": [Property(name="text", data_type=DataType.TEXT, skip_vectorization=True)]}, + ], +) +def test_config_property_flags_do_not_warn(kwargs: dict) -> None: + config = _CollectionConfigCreate(name="test", **kwargs) + with warnings.catch_warnings(): + warnings.simplefilter("error") + config._to_dict() + + TEST_CONFIG_WITH_GENERATIVE = [ ( Configure.Generative.openai(), diff --git a/weaviate/collections/classes/config.py b/weaviate/collections/classes/config.py index 81456001f..4e20c4692 100644 --- a/weaviate/collections/classes/config.py +++ b/weaviate/collections/classes/config.py @@ -2488,11 +2488,13 @@ class Property(_ConfigCreateModel): index_searchable: Whether the property should be searchable in the inverted index. nested_properties: nested properties for data type OBJECT and OBJECT_ARRAY`. skip_vectorization: Whether to skip vectorization of the property. Defaults to `False`. + Only applies with the legacy `vectorizer_config`. For `vector_config`, use `source_properties` instead. text_analyzer: Text analysis options for the property. Configures ASCII folding behavior for text and text[] properties using an inverted index. Immutable after the property is created. tokenization: The tokenization method to use for the inverted index. Defaults to `None`. vectorize_property_name: Whether to vectorize the property name. Defaults to `True`. + Only applies with the legacy `vectorizer_config`. """ name: str @@ -2782,6 +2784,7 @@ def __add_props( ) -> None: if props is None: return + self.__warn_vectorization_flags_ignored(props) existing_props = ret_dict.get("properties", []) existing_props.extend( [ @@ -2803,6 +2806,24 @@ def __add_props( ) ret_dict["properties"] = existing_props + def __warn_vectorization_flags_ignored( + self, props: Sequence[Union[Property, ReferencePropertyBase]] + ) -> None: + # TODO - consider removing when legacy vectoriser removal done + # The property flags are only mapped into moduleConfig for vectorizer_config. + if self.vectorConfig is None: + return + vector_configs = ( + [self.vectorConfig] + if isinstance(self.vectorConfig, VectorConfigCreate) + else self.vectorConfig + ) + if all(conf.vectorizer.vectorizer == Vectorizers.NONE for conf in vector_configs): + return + for prop in props: + if isinstance(prop, Property) and "skip_vectorization" in prop.model_fields_set: + _Warnings.skip_vectorization_ignored_with_vector_config(prop.name) + class _Replication: @staticmethod diff --git a/weaviate/warnings.py b/weaviate/warnings.py index b3de774aa..02c958060 100644 --- a/weaviate/warnings.py +++ b/weaviate/warnings.py @@ -314,6 +314,15 @@ def datetime_empty_string() -> None: stacklevel=1, ) + @staticmethod + def skip_vectorization_ignored_with_vector_config(property_name: str) -> None: + warnings.warn( + message=f"""Dep032: `skip_vectorization` on property "{property_name}" has no effect when the collection is + created with `vector_config`. Use `source_properties` on the vector to choose which properties are vectorized.""", + category=DeprecationWarning, + stacklevel=1, + ) + @staticmethod def create_skips_vectors_without_index(vectors: list) -> None: warnings.warn(