Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions test/collection/test_config.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from typing import List, Union

import pytest
Expand Down Expand Up @@ -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(),
Expand Down
21 changes: 21 additions & 0 deletions weaviate/collections/classes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
[
Expand All @@ -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
Expand Down
9 changes: 9 additions & 0 deletions weaviate/warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading