Home / Function/ test_aincremental_delete() — langchain Function Reference

test_aincremental_delete() — langchain Function Reference

Architecture documentation for the test_aincremental_delete() function in test_indexing.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  55d976ff_2126_6b1c_3ea4_76901cef58a2["test_aincremental_delete()"]
  576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978["test_indexing.py"]
  55d976ff_2126_6b1c_3ea4_76901cef58a2 -->|defined in| 576ad89d_c8dc_eddf_9cd2_c8ae0e7c9978
  cd9b8c73_107c_0850_0af6_a10b4e37e48a["lazy_load()"]
  55d976ff_2126_6b1c_3ea4_76901cef58a2 -->|calls| cd9b8c73_107c_0850_0af6_a10b4e37e48a
  style 55d976ff_2126_6b1c_3ea4_76901cef58a2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/indexing/test_indexing.py lines 1844–1954

async def test_aincremental_delete(
    arecord_manager: InMemoryRecordManager, vector_store: InMemoryVectorStore
) -> None:
    """Test indexing with incremental deletion strategy."""
    loader = ToyLoader(
        documents=[
            Document(
                page_content="This is a test document.",
                metadata={"source": "1"},
            ),
            Document(
                page_content="This is another document.",
                metadata={"source": "2"},
            ),
        ]
    )

    with patch.object(
        arecord_manager,
        "get_time",
        return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
    ):
        assert await aindex(
            loader.lazy_load(),
            arecord_manager,
            vector_store,
            cleanup="incremental",
            source_id_key="source",
            key_encoder="sha256",
        ) == {
            "num_added": 2,
            "num_deleted": 0,
            "num_skipped": 0,
            "num_updated": 0,
        }

    doc_texts = {
        # Ignoring type since doc should be in the store and not a None
        vector_store.get_by_ids([uid])[0].page_content
        for uid in vector_store.store
    }
    assert doc_texts == {"This is another document.", "This is a test document."}

    # Attempt to index again verify that nothing changes
    with patch.object(
        arecord_manager,
        "get_time",
        return_value=datetime(2021, 1, 2, tzinfo=timezone.utc).timestamp(),
    ):
        assert await aindex(
            loader.lazy_load(),
            arecord_manager,
            vector_store,
            cleanup="incremental",
            source_id_key="source",
            key_encoder="sha256",
        ) == {
            "num_added": 0,
            "num_deleted": 0,
            "num_skipped": 2,
            "num_updated": 0,
        }

    # Create 2 documents from the same source all with mutated content
    loader = ToyLoader(
        documents=[
            Document(
                page_content="mutated document 1",
                metadata={"source": "1"},
            ),
            Document(
                page_content="mutated document 2",
                metadata={"source": "1"},
            ),
            Document(
                page_content="This is another document.",  # <-- Same as original
                metadata={"source": "2"},
            ),
        ]
    )

Subdomains

Calls

Frequently Asked Questions

What does test_aincremental_delete() do?
test_aincremental_delete() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/indexing/test_indexing.py.
Where is test_aincremental_delete() defined?
test_aincremental_delete() is defined in libs/core/tests/unit_tests/indexing/test_indexing.py at line 1844.
What does test_aincremental_delete() call?
test_aincremental_delete() calls 1 function(s): lazy_load.

Analyze Your Own Codebase

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

Try Supermodel Free