Home / Class/ MyRunnable Class — langchain Architecture

MyRunnable Class — langchain Architecture

Architecture documentation for the MyRunnable class in test_configurable.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b8d79083_5cef_9939_bc5f_612203bb159c["MyRunnable"]
  ec7909ee_ece0_2780_95cd_f0c5229fc46d["test_configurable.py"]
  b8d79083_5cef_9939_bc5f_612203bb159c -->|defined in| ec7909ee_ece0_2780_95cd_f0c5229fc46d
  2db5828a_d332_f398_5438_035b22b1b616["my_error()"]
  b8d79083_5cef_9939_bc5f_612203bb159c -->|method| 2db5828a_d332_f398_5438_035b22b1b616
  02beccce_24ab_0c6b_76d4_ef3daac5d906["build_extra()"]
  b8d79083_5cef_9939_bc5f_612203bb159c -->|method| 02beccce_24ab_0c6b_76d4_ef3daac5d906
  881be650_c38e_3e60_74cf_8cdfc48f60b9["invoke()"]
  b8d79083_5cef_9939_bc5f_612203bb159c -->|method| 881be650_c38e_3e60_74cf_8cdfc48f60b9
  52678a78_ef5f_195a_cb54_4c667a93774e["my_custom_function()"]
  b8d79083_5cef_9939_bc5f_612203bb159c -->|method| 52678a78_ef5f_195a_cb54_4c667a93774e
  cd1de384_a13b_a91a_7bed_d86ffbf38e59["my_custom_function_w_config()"]
  b8d79083_5cef_9939_bc5f_612203bb159c -->|method| cd1de384_a13b_a91a_7bed_d86ffbf38e59
  57238a2b_7053_1eb1_fdbb_3907bc4b5d51["my_custom_function_w_kw_config()"]
  b8d79083_5cef_9939_bc5f_612203bb159c -->|method| 57238a2b_7053_1eb1_fdbb_3907bc4b5d51

Relationship Graph

Source Code

libs/core/tests/unit_tests/runnables/test_configurable.py lines 14–57

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

Frequently Asked Questions

What is the MyRunnable class?
MyRunnable is a class in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_configurable.py.
Where is MyRunnable defined?
MyRunnable is defined in libs/core/tests/unit_tests/runnables/test_configurable.py at line 14.

Analyze Your Own Codebase

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

Try Supermodel Free