Home / Function/ test_custom_event_nested() — langchain Function Reference

test_custom_event_nested() — langchain Function Reference

Architecture documentation for the test_custom_event_nested() function in test_runnable_events_v2.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  32caf57d_0fc5_7a24_8c1e_4186a5fe1327["test_custom_event_nested()"]
  33c02978_2077_5819_7048_bc2a81e80625["test_runnable_events_v2.py"]
  32caf57d_0fc5_7a24_8c1e_4186a5fe1327 -->|defined in| 33c02978_2077_5819_7048_bc2a81e80625
  716d2a5e_dc8e_3cae_e044_b56b06bee655["_collect_events()"]
  32caf57d_0fc5_7a24_8c1e_4186a5fe1327 -->|calls| 716d2a5e_dc8e_3cae_e044_b56b06bee655
  style 32caf57d_0fc5_7a24_8c1e_4186a5fe1327 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/runnables/test_runnable_events_v2.py lines 2673–2773

async def test_custom_event_nested() -> None:
    """Test adhoc event in a nested chain."""

    @RunnableLambda[int, int]
    async def foo(x: int, config: RunnableConfig) -> int:
        """Simple function that emits some adhoc events."""
        await adispatch_custom_event("event1", {"x": x}, config=config)
        await adispatch_custom_event("event2", "foo", config=config)
        return x + 1

    run_id = uuid.UUID(int=7)
    child_run_id = uuid.UUID(int=8)

    @RunnableLambda[int, int]
    async def bar(x: int, config: RunnableConfig) -> int:
        """Simple function that emits some adhoc events."""
        return await foo.ainvoke(
            x,
            {"run_id": child_run_id, **config},
        )

    events = await _collect_events(
        bar.astream_events(
            1,
            version="v2",
            config={"run_id": run_id},
        ),
        with_nulled_ids=False,
    )

    run_id = str(run_id)  # type: ignore[assignment]
    child_run_id = str(child_run_id)  # type: ignore[assignment]

    _assert_events_equal_allow_superset_metadata(
        events,
        [
            {
                "data": {"input": 1},
                "event": "on_chain_start",
                "metadata": {},
                "name": "bar",
                "parent_ids": [],
                "run_id": "00000000-0000-0000-0000-000000000007",
                "tags": [],
            },
            {
                "data": {"input": 1},
                "event": "on_chain_start",
                "metadata": {},
                "name": "foo",
                "parent_ids": ["00000000-0000-0000-0000-000000000007"],
                "run_id": "00000000-0000-0000-0000-000000000008",
                "tags": [],
            },
            {
                "data": {"x": 1},
                "event": "on_custom_event",
                "metadata": {},
                "name": "event1",
                "parent_ids": ["00000000-0000-0000-0000-000000000007"],
                "run_id": "00000000-0000-0000-0000-000000000008",
                "tags": [],
            },
            {
                "data": "foo",
                "event": "on_custom_event",
                "metadata": {},
                "name": "event2",
                "parent_ids": ["00000000-0000-0000-0000-000000000007"],
                "run_id": "00000000-0000-0000-0000-000000000008",
                "tags": [],
            },
            {
                "data": {"input": 1, "output": 2},
                "event": "on_chain_end",
                "metadata": {},
                "name": "foo",
                "parent_ids": ["00000000-0000-0000-0000-000000000007"],
                "run_id": "00000000-0000-0000-0000-000000000008",
                "tags": [],
            },

Domain

Subdomains

Frequently Asked Questions

What does test_custom_event_nested() do?
test_custom_event_nested() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable_events_v2.py.
Where is test_custom_event_nested() defined?
test_custom_event_nested() is defined in libs/core/tests/unit_tests/runnables/test_runnable_events_v2.py at line 2673.
What does test_custom_event_nested() call?
test_custom_event_nested() calls 1 function(s): _collect_events.

Analyze Your Own Codebase

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

Try Supermodel Free