Home / File/ test_config.py — langchain Source File

test_config.py — langchain Source File

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

File python CoreAbstractions Serialization 11 imports 4 functions

Entity Profile

Dependency Diagram

graph LR
  8b969f31_85c5_bfa6_c6dd_4c29568f829f["test_config.py"]
  7025b240_fdc3_cf68_b72f_f41dac94566b["json"]
  8b969f31_85c5_bfa6_c6dd_4c29568f829f --> 7025b240_fdc3_cf68_b72f_f41dac94566b
  8dfa0cac_d802_3ccd_f710_43a5e70da3a5["uuid"]
  8b969f31_85c5_bfa6_c6dd_4c29568f829f --> 8dfa0cac_d802_3ccd_f710_43a5e70da3a5
  e7c46dc4_ca3a_87ac_156f_0aa3d9b9d3f4["contextvars"]
  8b969f31_85c5_bfa6_c6dd_4c29568f829f --> e7c46dc4_ca3a_87ac_156f_0aa3d9b9d3f4
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  8b969f31_85c5_bfa6_c6dd_4c29568f829f --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  8b969f31_85c5_bfa6_c6dd_4c29568f829f --> 120e2591_3e15_b895_72b6_cb26195e40a6
  e8ec017e_6c91_4b34_675f_2a96c5aa9be6["langchain_core.callbacks.manager"]
  8b969f31_85c5_bfa6_c6dd_4c29568f829f --> e8ec017e_6c91_4b34_675f_2a96c5aa9be6
  abb72023_d38b_8b3e_578b_e9c61bbab112["langchain_core.callbacks.stdout"]
  8b969f31_85c5_bfa6_c6dd_4c29568f829f --> abb72023_d38b_8b3e_578b_e9c61bbab112
  f21116c3_1640_4b87_430f_da973ee1de3f["langchain_core.callbacks.streaming_stdout"]
  8b969f31_85c5_bfa6_c6dd_4c29568f829f --> f21116c3_1640_4b87_430f_da973ee1de3f
  2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c["langchain_core.runnables"]
  8b969f31_85c5_bfa6_c6dd_4c29568f829f --> 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c
  2971f9da_6393_a3e3_610e_ace3d35ee978["langchain_core.runnables.config"]
  8b969f31_85c5_bfa6_c6dd_4c29568f829f --> 2971f9da_6393_a3e3_610e_ace3d35ee978
  8bf7b3ca_c639_e4bc_1078_4c3d567f3209["langchain_core.tracers.stdout"]
  8b969f31_85c5_bfa6_c6dd_4c29568f829f --> 8bf7b3ca_c639_e4bc_1078_4c3d567f3209
  style 8b969f31_85c5_bfa6_c6dd_4c29568f829f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import json
import uuid
from contextvars import copy_context
from typing import Any, cast

import pytest

from langchain_core.callbacks.manager import (
    AsyncCallbackManager,
    CallbackManager,
    atrace_as_chain_group,
    trace_as_chain_group,
)
from langchain_core.callbacks.stdout import StdOutCallbackHandler
from langchain_core.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
from langchain_core.runnables import RunnableBinding, RunnablePassthrough
from langchain_core.runnables.config import (
    RunnableConfig,
    _set_config_context,
    ensure_config,
    merge_configs,
    run_in_executor,
)
from langchain_core.tracers.stdout import ConsoleCallbackHandler


def test_ensure_config() -> None:
    run_id = str(uuid.uuid4())
    arg: dict[str, Any] = {
        "something": "else",
        "metadata": {"foo": "bar"},
        "configurable": {"baz": "qux"},
        "callbacks": [StdOutCallbackHandler()],
        "tags": ["tag1", "tag2"],
        "max_concurrency": 1,
        "recursion_limit": 100,
        "run_id": run_id,
        "run_name": "test",
    }
    arg_str = json.dumps({**arg, "callbacks": []})
    ctx = copy_context()
    ctx.run(
        _set_config_context,
        {
            "callbacks": [ConsoleCallbackHandler()],
            "metadata": {"a": "b"},
            "configurable": {"c": "d"},
            "tags": ["tag3", "tag4"],
        },
    )
    config = ctx.run(ensure_config, cast("RunnableConfig", arg))
    assert len(arg["callbacks"]) == 1, (
        "ensure_config should not modify the original config"
    )
    assert json.dumps({**arg, "callbacks": []}) == arg_str, (
        "ensure_config should not modify the original config"
    )
    assert config is not arg
    assert config["callbacks"] is not arg["callbacks"]
    assert config["metadata"] is not arg["metadata"]
// ... (104 more lines)

Subdomains

Dependencies

  • contextvars
  • json
  • langchain_core.callbacks.manager
  • langchain_core.callbacks.stdout
  • langchain_core.callbacks.streaming_stdout
  • langchain_core.runnables
  • langchain_core.runnables.config
  • langchain_core.tracers.stdout
  • pytest
  • typing
  • uuid

Frequently Asked Questions

What does test_config.py do?
test_config.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_config.py?
test_config.py defines 4 function(s): test_config_arbitrary_keys, test_ensure_config, test_merge_config_callbacks, test_run_in_executor.
What does test_config.py depend on?
test_config.py imports 11 module(s): contextvars, json, langchain_core.callbacks.manager, langchain_core.callbacks.stdout, langchain_core.callbacks.streaming_stdout, langchain_core.runnables, langchain_core.runnables.config, langchain_core.tracers.stdout, and 3 more.
Where is test_config.py in the architecture?
test_config.py is located at libs/core/tests/unit_tests/runnables/test_config.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/core/tests/unit_tests/runnables).

Analyze Your Own Codebase

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

Try Supermodel Free