TestRunnableSequenceParallelTraceNesting Class — langchain Architecture
Architecture documentation for the TestRunnableSequenceParallelTraceNesting class in test_tracing_interops.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD bf7edb6a_efe2_778a_5204_a2813723040a["TestRunnableSequenceParallelTraceNesting"] 0944f1ae_0eea_e3a0_544b_8617adb53dbc["test_tracing_interops.py"] bf7edb6a_efe2_778a_5204_a2813723040a -->|defined in| 0944f1ae_0eea_e3a0_544b_8617adb53dbc 2e2a5c84_688b_d142_b405_7535f71a9d98["_setup()"] bf7edb6a_efe2_778a_5204_a2813723040a -->|method| 2e2a5c84_688b_d142_b405_7535f71a9d98 3719e2cc_93ad_455c_1a0f_e9a777837449["_create_parent()"] bf7edb6a_efe2_778a_5204_a2813723040a -->|method| 3719e2cc_93ad_455c_1a0f_e9a777837449 500b76bd_3ec5_98ce_3a9c_3f62ed483d4a["_check_posts()"] bf7edb6a_efe2_778a_5204_a2813723040a -->|method| 500b76bd_3ec5_98ce_3a9c_3f62ed483d4a 94606c53_844b_2d78_abaf_9a0055c3e789["test_sync()"] bf7edb6a_efe2_778a_5204_a2813723040a -->|method| 94606c53_844b_2d78_abaf_9a0055c3e789 9628f893_1701_c3db_b87d_89de6bbf00e1["ainvoke()"] bf7edb6a_efe2_778a_5204_a2813723040a -->|method| 9628f893_1701_c3db_b87d_89de6bbf00e1 13f3d275_21f2_3aa0_4fc8_30a58c2bc56a["astream()"] bf7edb6a_efe2_778a_5204_a2813723040a -->|method| 13f3d275_21f2_3aa0_4fc8_30a58c2bc56a 8f33e18e_a0fc_e7b4_9f65_a036ff5e2f6b["abatch()"] bf7edb6a_efe2_778a_5204_a2813723040a -->|method| 8f33e18e_a0fc_e7b4_9f65_a036ff5e2f6b 353e1ca2_8a6c_ba21_9c45_8252973047c0["test_async()"] bf7edb6a_efe2_778a_5204_a2813723040a -->|method| 353e1ca2_8a6c_ba21_9c45_8252973047c0
Relationship Graph
Source Code
libs/core/tests/unit_tests/runnables/test_tracing_interops.py lines 262–432
class TestRunnableSequenceParallelTraceNesting:
@pytest.fixture(autouse=True)
def _setup(self) -> None:
self.tracer = _create_tracer_with_mocked_client()
@staticmethod
def _create_parent(
other_thing: Callable[
[int], Generator[int, None, None] | AsyncGenerator[int, None]
],
) -> RunnableLambda:
@RunnableLambda
def my_child_function(a: int) -> int:
return a + 2
parallel = RunnableParallel(
chain_result=my_child_function.with_config(tags=["atag"]),
other_thing=other_thing,
)
def before(x: int) -> int:
return x
def after(x: dict[str, Any]) -> int:
return int(x["chain_result"])
sequence = before | parallel | after
if isasyncgenfunction(other_thing):
@RunnableLambda
async def parent(a: int) -> int:
return await sequence.ainvoke(a)
else:
@RunnableLambda
def parent(a: int) -> int:
return sequence.invoke(a)
return parent
def _check_posts(self) -> None:
posts = _get_posts(self.tracer.client)
name_order = [
"parent",
"RunnableSequence",
"before",
"RunnableParallel<chain_result,other_thing>",
["my_child_function", "other_thing"],
"after",
]
expected_parents = {
"parent": None,
"RunnableSequence": "parent",
"before": "RunnableSequence",
"RunnableParallel<chain_result,other_thing>": "RunnableSequence",
"my_child_function": "RunnableParallel<chain_result,other_thing>",
"other_thing": "RunnableParallel<chain_result,other_thing>",
"after": "RunnableSequence",
}
assert len(posts) == sum(
1 if isinstance(n, str) else len(n) for n in name_order
)
prev_dotted_order = None
dotted_order_map = {}
id_map = {}
parent_id_map = {}
i = 0
for name in name_order:
if isinstance(name, list):
for n in name:
matching_post = next(
p for p in posts[i : i + len(name)] if p["name"] == n
)
assert matching_post
dotted_order = matching_post["dotted_order"]
if prev_dotted_order is not None:
assert dotted_order > prev_dotted_order
dotted_order_map[n] = dotted_order
id_map[n] = matching_post["id"]
parent_id_map[n] = matching_post.get("parent_run_id")
Source
Frequently Asked Questions
What is the TestRunnableSequenceParallelTraceNesting class?
TestRunnableSequenceParallelTraceNesting is a class in the langchain codebase, defined in libs/core/tests/unit_tests/runnables/test_tracing_interops.py.
Where is TestRunnableSequenceParallelTraceNesting defined?
TestRunnableSequenceParallelTraceNesting is defined in libs/core/tests/unit_tests/runnables/test_tracing_interops.py at line 262.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free