Add test to confirm only one root run is produced

This commit is contained in:
Nuno Campos
2024-09-04 12:56:32 -07:00
parent af780f97a4
commit dc10b3aa8e
2 changed files with 13 additions and 3 deletions
+7 -1
View File
@@ -9823,12 +9823,18 @@ def test_send_to_nested_graphs(
graph = builder.compile(checkpointer=checkpointer)
config = {"configurable": {"thread_id": "1"}}
tracer = FakeTracer()
# invoke and pause at nested interrupt
assert graph.invoke({"subjects": ["cats", "dogs"]}, config=config) == {
assert graph.invoke(
{"subjects": ["cats", "dogs"]}, config={**config, "callbacks": [tracer]}
) == {
"subjects": ["cats", "dogs"],
"jokes": [],
}
assert len(tracer.runs) == 1, "Should produce exactly 1 root run"
# check state
outer_state = graph.get_state(config)
assert outer_state == StateSnapshot(
values={"subjects": ["cats", "dogs"], "jokes": []},
+6 -2
View File
@@ -8467,15 +8467,19 @@ async def test_send_to_nested_graphs(checkpointer_name: str) -> None:
async with awith_checkpointer(checkpointer_name) as checkpointer:
graph = builder.compile(checkpointer=checkpointer)
config = {"configurable": {"thread_id": "1"}}
tracer = FakeTracer()
# invoke and pause at nested interrupt
assert await graph.ainvoke({"subjects": ["cats", "dogs"]}, config=config) == {
assert await graph.ainvoke(
{"subjects": ["cats", "dogs"]}, config={**config, "callbacks": [tracer]}
) == {
"subjects": ["cats", "dogs"],
"jokes": [],
}
assert len(tracer.runs) == 1, "Should produce exactly 1 root run"
# check state
outer_state = await graph.aget_state(config)
assert outer_state == StateSnapshot(
values={"subjects": ["cats", "dogs"], "jokes": []},
tasks=(