test_runnable_branch_invoke_callbacks() — langchain Function Reference
Architecture documentation for the test_runnable_branch_invoke_callbacks() function in test_runnable.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD bbcfa861_9640_f3bf_0c7e_bb3cf1d915cc["test_runnable_branch_invoke_callbacks()"] 26df6ad8_0189_51d0_c3c1_6c3248893ff5["test_runnable.py"] bbcfa861_9640_f3bf_0c7e_bb3cf1d915cc -->|defined in| 26df6ad8_0189_51d0_c3c1_6c3248893ff5 fb618d44_c03b_ea8b_385b_2278dfb173d4["invoke()"] bbcfa861_9640_f3bf_0c7e_bb3cf1d915cc -->|calls| fb618d44_c03b_ea8b_385b_2278dfb173d4 style bbcfa861_9640_f3bf_0c7e_bb3cf1d915cc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_runnable.py lines 4602–4627
def test_runnable_branch_invoke_callbacks() -> None:
"""Verify that callbacks are correctly used in invoke."""
tracer = FakeTracer()
def raise_value_error(_: int) -> int:
"""Raise a value error."""
msg = "x is too large"
raise ValueError(msg)
branch = RunnableBranch[int, int](
(lambda x: x > 100, raise_value_error),
lambda x: x - 1,
)
assert branch.invoke(1, config={"callbacks": [tracer]}) == 0
assert len(tracer.runs) == 1
assert tracer.runs[0].error is None
assert tracer.runs[0].outputs == {"output": 0}
# Check that the chain on end is invoked
with pytest.raises(ValueError, match="x is too large"):
branch.invoke(1000, config={"callbacks": [tracer]})
assert len(tracer.runs) == 2
assert "ValueError('x is too large')" in str(tracer.runs[1].error)
assert not tracer.runs[1].outputs
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does test_runnable_branch_invoke_callbacks() do?
test_runnable_branch_invoke_callbacks() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_runnable.py.
Where is test_runnable_branch_invoke_callbacks() defined?
test_runnable_branch_invoke_callbacks() is defined in libs/core/tests/unit_tests/runnables/test_runnable.py at line 4602.
What does test_runnable_branch_invoke_callbacks() call?
test_runnable_branch_invoke_callbacks() calls 1 function(s): invoke.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free