Home / File/ test_configurable.py — langchain Source File

test_configurable.py — langchain Source File

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

File python CoreAbstractions RunnableInterface 5 imports 5 functions 2 classes

Entity Profile

Dependency Diagram

graph LR
  ec7909ee_ece0_2780_95cd_f0c5229fc46d["test_configurable.py"]
  8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"]
  ec7909ee_ece0_2780_95cd_f0c5229fc46d --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3
  120e2591_3e15_b895_72b6_cb26195e40a6["pytest"]
  ec7909ee_ece0_2780_95cd_f0c5229fc46d --> 120e2591_3e15_b895_72b6_cb26195e40a6
  6e58aaea_f08e_c099_3cc7_f9567bfb1ae7["pydantic"]
  ec7909ee_ece0_2780_95cd_f0c5229fc46d --> 6e58aaea_f08e_c099_3cc7_f9567bfb1ae7
  91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"]
  ec7909ee_ece0_2780_95cd_f0c5229fc46d --> 91721f45_4909_e489_8c1f_084f8bd87145
  2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c["langchain_core.runnables"]
  ec7909ee_ece0_2780_95cd_f0c5229fc46d --> 2ceb1686_0f8c_8ae0_36d1_7c0b702fda1c
  style ec7909ee_ece0_2780_95cd_f0c5229fc46d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from typing import Any

import pytest
from pydantic import ConfigDict, Field, model_validator
from typing_extensions import Self, override

from langchain_core.runnables import (
    ConfigurableField,
    RunnableConfig,
    RunnableSerializable,
)


class MyRunnable(RunnableSerializable[str, str]):
    my_property: str = Field(alias="my_property_alias")
    _my_hidden_property: str = ""

    model_config = ConfigDict(
        populate_by_name=True,
    )

    @model_validator(mode="before")
    @classmethod
    def my_error(cls, values: dict[str, Any]) -> Any:
        if "_my_hidden_property" in values:
            msg = "Cannot set _my_hidden_property"
            raise ValueError(msg)
        return values

    @model_validator(mode="after")
    def build_extra(self) -> Self:
        self._my_hidden_property = self.my_property
        return self

    @override
    def invoke(
        self, input: str, config: RunnableConfig | None = None, **kwargs: Any
    ) -> Any:
        return input + self._my_hidden_property

    def my_custom_function(self) -> str:
        return self.my_property

    def my_custom_function_w_config(
        self,
        config: RunnableConfig | None = None,
    ) -> str:
        _ = config
        return self.my_property

    def my_custom_function_w_kw_config(
        self,
        *,
        config: RunnableConfig | None = None,
    ) -> str:
        _ = config
        return self.my_property


class MyOtherRunnable(RunnableSerializable[str, str]):
// ... (214 more lines)

Subdomains

Dependencies

  • langchain_core.runnables
  • pydantic
  • pytest
  • typing
  • typing_extensions

Frequently Asked Questions

What does test_configurable.py do?
test_configurable.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_configurable.py?
test_configurable.py defines 5 function(s): test_alias_set_configurable, test_config_passthrough, test_config_passthrough_nested, test_doubly_set_configurable, test_field_alias_set_configurable.
What does test_configurable.py depend on?
test_configurable.py imports 5 module(s): langchain_core.runnables, pydantic, pytest, typing, typing_extensions.
Where is test_configurable.py in the architecture?
test_configurable.py is located at libs/core/tests/unit_tests/runnables/test_configurable.py (domain: CoreAbstractions, subdomain: RunnableInterface, 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