test_config_traceable_async_handoff() — langchain Function Reference
Architecture documentation for the test_config_traceable_async_handoff() function in test_tracing_interops.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ec7ffefe_6fbe_cda9_b1b3_722a7fb9a37b["test_config_traceable_async_handoff()"] 0944f1ae_0eea_e3a0_544b_8617adb53dbc["test_tracing_interops.py"] ec7ffefe_6fbe_cda9_b1b3_722a7fb9a37b -->|defined in| 0944f1ae_0eea_e3a0_544b_8617adb53dbc 7b80fc10_92d1_fc52_4aab_d37efa7bc889["_create_tracer_with_mocked_client()"] ec7ffefe_6fbe_cda9_b1b3_722a7fb9a37b -->|calls| 7b80fc10_92d1_fc52_4aab_d37efa7bc889 9628f893_1701_c3db_b87d_89de6bbf00e1["ainvoke()"] ec7ffefe_6fbe_cda9_b1b3_722a7fb9a37b -->|calls| 9628f893_1701_c3db_b87d_89de6bbf00e1 8c16b015_8380_d9f6_e698_f4a12f12a4f5["_get_posts()"] ec7ffefe_6fbe_cda9_b1b3_722a7fb9a37b -->|calls| 8c16b015_8380_d9f6_e698_f4a12f12a4f5 style ec7ffefe_6fbe_cda9_b1b3_722a7fb9a37b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_tracing_interops.py lines 162–224
async def test_config_traceable_async_handoff() -> None:
tracer = _create_tracer_with_mocked_client()
@traceable
def my_great_great_grandchild_function(a: int) -> int:
return a + 1
@RunnableLambda
def my_great_grandchild_function(a: int) -> int:
return my_great_great_grandchild_function(a)
@RunnableLambda
async def my_grandchild_function(a: int) -> int:
return my_great_grandchild_function.invoke(a)
@traceable
async def my_child_function(a: int) -> int:
return await my_grandchild_function.ainvoke(a) * 3
@traceable()
async def my_function(a: int) -> int:
return await my_child_function(a)
async def my_parent_function(a: int) -> int:
return await my_function(a)
my_parent_runnable = RunnableLambda(my_parent_function)
result = await my_parent_runnable.ainvoke(1, {"callbacks": [tracer]})
assert result == 6
posts = _get_posts(tracer.client)
# There should have been 6 runs created,
# one for each function invocation
assert len(posts) == 6
name_to_body = {post["name"]: post for post in posts}
ordered_names = [
"my_parent_function",
"my_function",
"my_child_function",
"my_grandchild_function",
"my_great_grandchild_function",
"my_great_great_grandchild_function",
]
trace_id = posts[0]["trace_id"]
last_dotted_order = None
parent_run_id = None
for name in ordered_names:
id_ = name_to_body[name]["id"]
parent_run_id_ = name_to_body[name].get("parent_run_id")
if parent_run_id_ is not None:
assert parent_run_id == parent_run_id_
assert name in name_to_body
# All within the same trace
assert name_to_body[name]["trace_id"] == trace_id
dotted_order: str = name_to_body[name]["dotted_order"]
assert dotted_order is not None
if last_dotted_order is not None:
assert dotted_order > last_dotted_order
assert dotted_order.startswith(last_dotted_order), (
"Unexpected dotted order for run"
f" {name}\n{dotted_order}\n{last_dotted_order}"
)
last_dotted_order = dotted_order
parent_run_id = id_
Domain
Subdomains
Source
Frequently Asked Questions
What does test_config_traceable_async_handoff() do?
test_config_traceable_async_handoff() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_tracing_interops.py.
Where is test_config_traceable_async_handoff() defined?
test_config_traceable_async_handoff() is defined in libs/core/tests/unit_tests/runnables/test_tracing_interops.py at line 162.
What does test_config_traceable_async_handoff() call?
test_config_traceable_async_handoff() calls 3 function(s): _create_tracer_with_mocked_client, _get_posts, ainvoke.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free