Home / File/ test_indexing.py — langchain Source File

test_indexing.py — langchain Source File

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

File python CoreAbstractions RunnableInterface 14 imports 48 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978["test_indexing.py"]
  cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7
  af34f08b_0ede_2b87_0db6_983d74ed0249["datetime"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> af34f08b_0ede_2b87_0db6_983d74ed0249
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  525a7d6f_f455_56e3_854a_c8a7da4a1417["unittest.mock"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> 525a7d6f_f455_56e3_854a_c8a7da4a1417
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> 120e2591_3e15_b895_72b6_cb26195e40a6
  a3f8313e_187d_b883_54b8_d68ee753b3c6["pytest_asyncio"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> a3f8313e_187d_b883_54b8_d68ee753b3c6
  2e073793_7bdb_2272_3b6f_82c878fdc38c["pytest_mock"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> 2e073793_7bdb_2272_3b6f_82c878fdc38c
  bc0c97a0_93eb_cfbc_6044_05825b687ba4["langchain_core.document_loaders.base"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> bc0c97a0_93eb_cfbc_6044_05825b687ba4
  c554676d_b731_47b2_a98f_c1c2d537c0aa["langchain_core.documents"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> c554676d_b731_47b2_a98f_c1c2d537c0aa
  bc46b61d_cfdf_3f6b_a9dd_ac2a328d84b3["langchain_core.embeddings"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> bc46b61d_cfdf_3f6b_a9dd_ac2a328d84b3
  a8fcc022_dc2b_29f4_4e44_b5c75941d529["langchain_core.indexing"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> a8fcc022_dc2b_29f4_4e44_b5c75941d529
  ffb0de41_b0f2_997d_ad3d_1a29fba34ab1["langchain_core.indexing.api"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> ffb0de41_b0f2_997d_ad3d_1a29fba34ab1
  f1b2b0eb_f384_a14e_5d97_566a3e577cd5["langchain_core.indexing.in_memory"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> f1b2b0eb_f384_a14e_5d97_566a3e577cd5
  d55af636_303c_0eb6_faee_20d89bd952d5["langchain_core.vectorstores"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 --> d55af636_303c_0eb6_faee_20d89bd952d5
  style 576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from collections.abc import AsyncIterator, Iterable, Iterator, Sequence
from datetime import datetime, timezone
from typing import (
    Any,
)
from unittest.mock import AsyncMock, MagicMock, patch

import pytest
import pytest_asyncio
from pytest_mock import MockerFixture

from langchain_core.document_loaders.base import BaseLoader
from langchain_core.documents import Document
from langchain_core.embeddings import DeterministicFakeEmbedding
from langchain_core.indexing import InMemoryRecordManager, aindex, index
from langchain_core.indexing.api import (
    IndexingException,
    _abatch,
    _get_document_with_hash,
)
from langchain_core.indexing.in_memory import InMemoryDocumentIndex
from langchain_core.vectorstores import InMemoryVectorStore, VectorStore


class ToyLoader(BaseLoader):
    """Toy loader that always returns the same documents."""

    def __init__(self, documents: Sequence[Document]) -> None:
        """Initialize with the documents to return."""
        self.documents = documents

    def lazy_load(
        self,
    ) -> Iterator[Document]:
        yield from self.documents

    async def alazy_load(
        self,
    ) -> AsyncIterator[Document]:
        for document in self.documents:
            yield document


@pytest.fixture
def record_manager() -> InMemoryRecordManager:
    """Timestamped set fixture."""
    record_manager = InMemoryRecordManager(namespace="hello")
    record_manager.create_schema()
    return record_manager


@pytest_asyncio.fixture
async def arecord_manager() -> InMemoryRecordManager:
    """Timestamped set fixture."""
    record_manager = InMemoryRecordManager(namespace="hello")
    await record_manager.acreate_schema()
    return record_manager


@pytest.fixture
// ... (2883 more lines)

Subdomains

Functions

Classes

Dependencies

  • collections.abc
  • datetime
  • langchain_core.document_loaders.base
  • langchain_core.documents
  • langchain_core.embeddings
  • langchain_core.indexing
  • langchain_core.indexing.api
  • langchain_core.indexing.in_memory
  • langchain_core.vectorstores
  • pytest
  • pytest_asyncio
  • pytest_mock
  • typing
  • unittest.mock

Frequently Asked Questions

What does test_indexing.py do?
test_indexing.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, RunnableInterface subdomain.
What functions are defined in test_indexing.py?
test_indexing.py defines 48 function(s): _to_async_iter, arecord_manager, record_manager, test_abatch, test_adeduplication, test_afull_cleanup_with_different_batchsize, test_aincremental_cleanup_with_different_batchsize, test_aincremental_delete, test_aincremental_fails_with_bad_source_ids, test_aindex_delete_full_recovery_after_deletion_failure, and 38 more.
What does test_indexing.py depend on?
test_indexing.py imports 14 module(s): collections.abc, datetime, langchain_core.document_loaders.base, langchain_core.documents, langchain_core.embeddings, langchain_core.indexing, langchain_core.indexing.api, langchain_core.indexing.in_memory, and 6 more.
Where is test_indexing.py in the architecture?
test_indexing.py is located at libs/core/tests/unit_tests/indexing/test_indexing.py (domain: CoreAbstractions, subdomain: RunnableInterface, directory: libs/core/tests/unit_tests/indexing).

Analyze Your Own Codebase

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

Try Supermodel Free