Home / File/ test_from_texts.py — langchain Source File

test_from_texts.py — langchain Source File

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

File python CoreAbstractions Serialization 9 imports 10 functions

Entity Profile

Dependency Diagram

graph LR
  1d7104d7_398c_51b4_cccd_e4a9968c8036["test_from_texts.py"]
  d47804b2_9963_be65_f855_93c7c6a0eab8["tempfile"]
  1d7104d7_398c_51b4_cccd_e4a9968c8036 --> d47804b2_9963_be65_f855_93c7c6a0eab8
  8dfa0cac_d802_3ccd_f710_43a5e70da3a5["uuid"]
  1d7104d7_398c_51b4_cccd_e4a9968c8036 --> 8dfa0cac_d802_3ccd_f710_43a5e70da3a5
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  1d7104d7_398c_51b4_cccd_e4a9968c8036 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"]
  1d7104d7_398c_51b4_cccd_e4a9968c8036 --> c554676d_b731_47b2_a98f_c1c2d537c0aa
  77801658_6b3a_bc26_7e54_388e5c04807d["langchain_qdrant"]
  1d7104d7_398c_51b4_cccd_e4a9968c8036 --> 77801658_6b3a_bc26_7e54_388e5c04807d
  4bea5943_7570_95b0_0e94_319d0e6c2547["langchain_qdrant.vectorstores"]
  1d7104d7_398c_51b4_cccd_e4a9968c8036 --> 4bea5943_7570_95b0_0e94_319d0e6c2547
  a50ef027_f19e_86a8_94ef_895b4566f94e["tests.integration_tests.common"]
  1d7104d7_398c_51b4_cccd_e4a9968c8036 --> a50ef027_f19e_86a8_94ef_895b4566f94e
  513f2bf4_0acd_14e4_0a43_45f7716ce101["tests.integration_tests.fixtures"]
  1d7104d7_398c_51b4_cccd_e4a9968c8036 --> 513f2bf4_0acd_14e4_0a43_45f7716ce101
  e9f800f2_8227_1095_42ef_324e02810451["qdrant_client"]
  1d7104d7_398c_51b4_cccd_e4a9968c8036 --> e9f800f2_8227_1095_42ef_324e02810451
  style 1d7104d7_398c_51b4_cccd_e4a9968c8036 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from __future__ import annotations

import tempfile
import uuid

import pytest  # type: ignore[import-not-found]
from langchain_core.documents import Document

from langchain_qdrant import Qdrant
from langchain_qdrant.vectorstores import QdrantException
from tests.integration_tests.common import (
    ConsistentFakeEmbeddings,
    assert_documents_equals,
)
from tests.integration_tests.fixtures import qdrant_locations


def test_qdrant_from_texts_stores_duplicated_texts() -> None:
    """Test end to end Qdrant.from_texts stores duplicated texts separately."""
    from qdrant_client import QdrantClient

    collection_name = uuid.uuid4().hex

    with tempfile.TemporaryDirectory() as tmpdir:
        vec_store = Qdrant.from_texts(
            ["abc", "abc"],
            ConsistentFakeEmbeddings(),
            collection_name=collection_name,
            path=str(tmpdir),
        )
        del vec_store

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


@pytest.mark.parametrize("batch_size", [1, 64])
@pytest.mark.parametrize("vector_name", [None, "my-vector"])
def test_qdrant_from_texts_stores_ids(batch_size: int, vector_name: str | None) -> None:
    """Test end to end Qdrant.from_texts stores provided ids."""
    from qdrant_client import QdrantClient

    collection_name = uuid.uuid4().hex
    with tempfile.TemporaryDirectory() as tmpdir:
        ids = [
            "fa38d572-4c31-4579-aedc-1960d79df6df",
            "cdc1aa36-d6ab-4fb2-8a94-56674fd27484",
        ]
        vec_store = Qdrant.from_texts(
            ["abc", "def"],
            ConsistentFakeEmbeddings(),
            ids=ids,
            collection_name=collection_name,
            path=str(tmpdir),
            batch_size=batch_size,
            vector_name=vector_name,
        )
        del vec_store

        client = QdrantClient(path=str(tmpdir))
// ... (228 more lines)

Subdomains

Dependencies

  • langchain_core.documents
  • langchain_qdrant
  • langchain_qdrant.vectorstores
  • pytest
  • qdrant_client
  • tempfile
  • tests.integration_tests.common
  • tests.integration_tests.fixtures
  • uuid

Frequently Asked Questions

What does test_from_texts.py do?
test_from_texts.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What functions are defined in test_from_texts.py?
test_from_texts.py defines 10 function(s): test_from_texts_passed_optimizers_config_and_on_disk_payload, test_qdrant_from_texts_raises_error_on_different_dimensionality, test_qdrant_from_texts_raises_error_on_different_distance, test_qdrant_from_texts_raises_error_on_different_vector_name, test_qdrant_from_texts_recreates_collection_on_force_recreate, test_qdrant_from_texts_reuses_same_collection, test_qdrant_from_texts_stores_duplicated_texts, test_qdrant_from_texts_stores_embeddings_as_named_vectors, test_qdrant_from_texts_stores_ids, test_qdrant_from_texts_stores_metadatas.
What does test_from_texts.py depend on?
test_from_texts.py imports 9 module(s): langchain_core.documents, langchain_qdrant, langchain_qdrant.vectorstores, pytest, qdrant_client, tempfile, tests.integration_tests.common, tests.integration_tests.fixtures, and 1 more.
Where is test_from_texts.py in the architecture?
test_from_texts.py is located at libs/partners/qdrant/tests/integration_tests/test_from_texts.py (domain: CoreAbstractions, subdomain: Serialization, 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