Home / File/ test_from_existing_collection.py — langchain Source File

test_from_existing_collection.py — langchain Source File

Architecture documentation for test_from_existing_collection.py, a python file in the langchain codebase. 6 imports, 0 dependents.

File python CoreAbstractions MessageSchema 6 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  5092e147_c608_491e_dcb9_126699c9a019["test_from_existing_collection.py"]
  d47804b2_9963_be65_f855_93c7c6a0eab8["tempfile"]
  5092e147_c608_491e_dcb9_126699c9a019 --> d47804b2_9963_be65_f855_93c7c6a0eab8
  8dfa0cac_d802_3ccd_f710_43a5e70da3a5["uuid"]
  5092e147_c608_491e_dcb9_126699c9a019 --> 8dfa0cac_d802_3ccd_f710_43a5e70da3a5
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  5092e147_c608_491e_dcb9_126699c9a019 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  77801658_6b3a_bc26_7e54_388e5c04807d["langchain_qdrant"]
  5092e147_c608_491e_dcb9_126699c9a019 --> 77801658_6b3a_bc26_7e54_388e5c04807d
  a50ef027_f19e_86a8_94ef_895b4566f94e["tests.integration_tests.common"]
  5092e147_c608_491e_dcb9_126699c9a019 --> a50ef027_f19e_86a8_94ef_895b4566f94e
  e9f800f2_8227_1095_42ef_324e02810451["qdrant_client"]
  5092e147_c608_491e_dcb9_126699c9a019 --> e9f800f2_8227_1095_42ef_324e02810451
  style 5092e147_c608_491e_dcb9_126699c9a019 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import tempfile
import uuid

import pytest  # type: ignore[import-not-found]

from langchain_qdrant import Qdrant
from tests.integration_tests.common import ConsistentFakeEmbeddings


@pytest.mark.parametrize("vector_name", ["custom-vector"])
def test_qdrant_from_existing_collection_uses_same_collection(vector_name: str) -> None:
    """Test if the Qdrant.from_existing_collection reuses the same collection."""
    from qdrant_client import QdrantClient

    collection_name = uuid.uuid4().hex
    with tempfile.TemporaryDirectory() as tmpdir:
        docs = ["foo"]
        qdrant = Qdrant.from_texts(
            docs,
            embedding=ConsistentFakeEmbeddings(),
            path=str(tmpdir),
            collection_name=collection_name,
            vector_name=vector_name,
        )
        del qdrant

        qdrant = Qdrant.from_existing_collection(
            embedding=ConsistentFakeEmbeddings(),
            path=str(tmpdir),
            collection_name=collection_name,
            vector_name=vector_name,
        )
        qdrant.add_texts(["baz", "bar"])
        del qdrant

        client = QdrantClient(path=str(tmpdir))
        assert client.count(collection_name).count == 3

Subdomains

Dependencies

  • langchain_qdrant
  • pytest
  • qdrant_client
  • tempfile
  • tests.integration_tests.common
  • uuid

Frequently Asked Questions

What does test_from_existing_collection.py do?
test_from_existing_collection.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, MessageSchema subdomain.
What functions are defined in test_from_existing_collection.py?
test_from_existing_collection.py defines 1 function(s): test_qdrant_from_existing_collection_uses_same_collection.
What does test_from_existing_collection.py depend on?
test_from_existing_collection.py imports 6 module(s): langchain_qdrant, pytest, qdrant_client, tempfile, tests.integration_tests.common, uuid.
Where is test_from_existing_collection.py in the architecture?
test_from_existing_collection.py is located at libs/partners/qdrant/tests/integration_tests/test_from_existing_collection.py (domain: CoreAbstractions, subdomain: MessageSchema, directory: libs/partners/qdrant/tests/integration_tests).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free