From 0891cc1864c74bfe6c2c19b0937397d136796eff Mon Sep 17 00:00:00 2001 From: vbarda Date: Mon, 22 Jul 2024 21:18:42 -0400 Subject: [PATCH] comments / bring back sleep --- libs/langgraph/tests/test_pregel.py | 4 ++++ libs/langgraph/tests/test_pregel_async.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/libs/langgraph/tests/test_pregel.py b/libs/langgraph/tests/test_pregel.py index d90a83ab8..23727aded 100644 --- a/libs/langgraph/tests/test_pregel.py +++ b/libs/langgraph/tests/test_pregel.py @@ -8457,6 +8457,7 @@ def test_nested_graph_interrupts_parallel(checkpointer: BaseCheckpointSaver) -> my_other_key: str def inner_1(state: InnerState): + time.sleep(0.1) return {"my_key": "got here", "my_other_key": state["my_key"]} def inner_2(state: InnerState): @@ -8503,6 +8504,9 @@ def test_nested_graph_interrupts_parallel(checkpointer: BaseCheckpointSaver) -> "my_key": "got here and there and parallel and back again", } + # below combo of assertions is asserting two things + # - outer_1 finishes before inner interrupts (because we see its output in stream, which only happens after node finishes) + # - the writes of outer are persisted in 1st call and used in 2nd call, ie outer isnt called again (because we dont see outer_1 output again in 2nd stream) # test stream updates w/ nested interrupt config = {"configurable": {"thread_id": "2"}} assert [*app.stream({"my_key": ""}, config)] == [ diff --git a/libs/langgraph/tests/test_pregel_async.py b/libs/langgraph/tests/test_pregel_async.py index 424d63af8..e906ecf87 100644 --- a/libs/langgraph/tests/test_pregel_async.py +++ b/libs/langgraph/tests/test_pregel_async.py @@ -6984,6 +6984,7 @@ async def test_nested_graph_interrupts_parallel( my_other_key: str async def inner_1(state: InnerState): + await asyncio.sleep(0.1) return {"my_key": "got here", "my_other_key": state["my_key"]} async def inner_2(state: InnerState): @@ -7030,6 +7031,9 @@ async def test_nested_graph_interrupts_parallel( "my_key": "got here and there and parallel and back again", } + # below combo of assertions is asserting two things + # - outer_1 finishes before inner interrupts (because we see its output in stream, which only happens after node finishes) + # - the writes of outer are persisted in 1st call and used in 2nd call, ie outer isnt called again (because we dont see outer_1 output again in 2nd stream) # test stream updates w/ nested interrupt config = {"configurable": {"thread_id": "2"}} assert [c async for c in app.astream({"my_key": ""}, config)] == [