Validator

This module contains functionality related to the the validator module for embedding.vector_stores.qdrant.

Validator

QdrantVectorStoreValidator

Bases: BaseVectorStoreValidator

Validator for Qdrant vector store configuration.

Validates collection settings and existence for Qdrant vector store backend.

Attributes:
  • configuration

    Settings for vector store

  • client

    Client for Qdrant interactions

Source code in src/embedding/vector_stores/qdrant/validator.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
class QdrantVectorStoreValidator(BaseVectorStoreValidator):
    """Validator for Qdrant vector store configuration.

    Validates collection settings and existence for Qdrant
    vector store backend.

    Attributes:
        configuration: Settings for vector store
        client: Client for Qdrant interactions
    """

    def __init__(
        self,
        configuration: QDrantVectorStoreConfiguration,
        client: QdrantClient,
    ):
        """Initialize validator with configuration and client.

        Args:
            configuration: Qdrant vector store settings
            client: Client for Qdrant operations
        """
        self.configuration = configuration
        self.client = client

    def validate(self) -> None:
        """Validate the Qdrant vector store settings.

        Performs validation checks on the provided configuration
        to ensure compatibility with Qdrant backend requirements.
        """
        self.validate_collection()

    def validate_collection(self) -> None:
        """Validate Qdrant collection existence.

        Checks if the specified collection already exists in the Qdrant
        database and raises an exception if it does, preventing
        unintentional overwriting of existing collections.

        Raises:
            CollectionExistsException: If collection already exists
                in the Qdrant database with the specified name
        """
        collection_name = self.configuration.collection_name
        if self.client.collection_exists(collection_name):
            raise CollectionExistsException(collection_name)

__init__(configuration, client)

Initialize validator with configuration and client.

Parameters:
  • configuration (QDrantVectorStoreConfiguration) –

    Qdrant vector store settings

  • client (QdrantClient) –

    Client for Qdrant operations

Source code in src/embedding/vector_stores/qdrant/validator.py
25
26
27
28
29
30
31
32
33
34
35
36
37
def __init__(
    self,
    configuration: QDrantVectorStoreConfiguration,
    client: QdrantClient,
):
    """Initialize validator with configuration and client.

    Args:
        configuration: Qdrant vector store settings
        client: Client for Qdrant operations
    """
    self.configuration = configuration
    self.client = client

validate()

Validate the Qdrant vector store settings.

Performs validation checks on the provided configuration to ensure compatibility with Qdrant backend requirements.

Source code in src/embedding/vector_stores/qdrant/validator.py
39
40
41
42
43
44
45
def validate(self) -> None:
    """Validate the Qdrant vector store settings.

    Performs validation checks on the provided configuration
    to ensure compatibility with Qdrant backend requirements.
    """
    self.validate_collection()

validate_collection()

Validate Qdrant collection existence.

Checks if the specified collection already exists in the Qdrant database and raises an exception if it does, preventing unintentional overwriting of existing collections.

Raises:
  • CollectionExistsException

    If collection already exists in the Qdrant database with the specified name

Source code in src/embedding/vector_stores/qdrant/validator.py
47
48
49
50
51
52
53
54
55
56
57
58
59
60
def validate_collection(self) -> None:
    """Validate Qdrant collection existence.

    Checks if the specified collection already exists in the Qdrant
    database and raises an exception if it does, preventing
    unintentional overwriting of existing collections.

    Raises:
        CollectionExistsException: If collection already exists
            in the Qdrant database with the specified name
    """
    collection_name = self.configuration.collection_name
    if self.client.collection_exists(collection_name):
        raise CollectionExistsException(collection_name)

QdrantVectorStoreValidatorFactory

Bases: SingletonFactory

Factory for creating Qdrant vector store validators.

Implements the singleton pattern to ensure only one validator instance exists for each unique configuration.

Source code in src/embedding/vector_stores/qdrant/validator.py
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
class QdrantVectorStoreValidatorFactory(SingletonFactory):
    """Factory for creating Qdrant vector store validators.

    Implements the singleton pattern to ensure only one validator
    instance exists for each unique configuration.
    """

    _configuration_class: Type = QDrantVectorStoreConfiguration

    @classmethod
    def _create_instance(
        cls, configuration: QDrantVectorStoreConfiguration
    ) -> QdrantVectorStoreValidator:
        """Creates a Qdrant validator based on provided configuration.

        Instantiates a new validator with the appropriate client
        for the given configuration.

        Args:
            configuration: QDrant connection configuration.

        Returns:
            QdrantVectorStoreValidator: Configured validator instance.
        """
        client = QdrantClientFactory.create(configuration)
        return QdrantVectorStoreValidator(
            configuration=configuration, client=client
        )