From 6a9ca8d67e084b9a7f145dd54d02b6059014c77c Mon Sep 17 00:00:00 2001 From: William Fu-Hinthorn <13333726+hinthornw@users.noreply.github.com> Date: Tue, 10 Jun 2025 17:59:41 -0700 Subject: [PATCH] Update existing --- libs/langgraph/tests/test_large_cases.py | 94 +----------------- .../langgraph/tests/test_large_cases_async.py | 96 +------------------ libs/langgraph/tests/test_pregel.py | 7 +- libs/langgraph/tests/test_pregel_async.py | 7 +- 4 files changed, 12 insertions(+), 192 deletions(-) diff --git a/libs/langgraph/tests/test_large_cases.py b/libs/langgraph/tests/test_large_cases.py index c19202bf8..04ff8e5c6 100644 --- a/libs/langgraph/tests/test_large_cases.py +++ b/libs/langgraph/tests/test_large_cases.py @@ -4213,44 +4213,6 @@ def test_doubly_nested_graph_state( # get child graph history child_history = list(app.get_state_history(outer_history[1].tasks[0].state)) assert child_history == [ - StateSnapshot( - values={"my_key": "hi my value here and there"}, - next=(), - config={ - "configurable": { - "thread_id": "1", - "checkpoint_ns": AnyStr("child:"), - "checkpoint_id": AnyStr(), - "checkpoint_map": AnyDict( - {"": AnyStr(), AnyStr("child:"): AnyStr()} - ), - } - }, - metadata={ - "source": "loop", - "step": 1, - "parents": {"": AnyStr()}, - "thread_id": "1", - "langgraph_node": "child", - "langgraph_path": [PULL, AnyStr("child")], - "langgraph_step": 2, - "langgraph_triggers": ["branch:to:child"], - "langgraph_checkpoint_ns": AnyStr("child:"), - }, - created_at=AnyStr(), - parent_config={ - "configurable": { - "thread_id": "1", - "checkpoint_ns": AnyStr("child:"), - "checkpoint_id": AnyStr(), - "checkpoint_map": AnyDict( - {"": AnyStr(), AnyStr("child:"): AnyStr()} - ), - } - }, - tasks=(), - interrupts=(), - ), StateSnapshot( values={"my_key": "hi my value"}, next=("child_1",), @@ -4295,62 +4257,8 @@ def test_doubly_nested_graph_state( ), ] # get grandchild graph history - grandchild_history = list(app.get_state_history(child_history[1].tasks[0].state)) + grandchild_history = list(app.get_state_history(child_history[0].tasks[0].state)) assert grandchild_history == [ - StateSnapshot( - values={"my_key": "hi my value here and there"}, - next=(), - config={ - "configurable": { - "thread_id": "1", - "checkpoint_ns": AnyStr(), - "checkpoint_id": AnyStr(), - "checkpoint_map": AnyDict( - { - "": AnyStr(), - AnyStr("child:"): AnyStr(), - AnyStr(re.compile(r"child:.+|child1:")): AnyStr(), - } - ), - } - }, - metadata={ - "source": "loop", - "step": 2, - "parents": AnyDict( - { - "": AnyStr(), - AnyStr("child:"): AnyStr(), - } - ), - "thread_id": "1", - "langgraph_checkpoint_ns": AnyStr("child:"), - "langgraph_node": "child_1", - "langgraph_path": [ - PULL, - AnyStr("child_1"), - ], - "langgraph_step": 1, - "langgraph_triggers": ["branch:to:child_1"], - }, - created_at=AnyStr(), - parent_config={ - "configurable": { - "thread_id": "1", - "checkpoint_ns": AnyStr(), - "checkpoint_id": AnyStr(), - "checkpoint_map": AnyDict( - { - "": AnyStr(), - AnyStr("child:"): AnyStr(), - AnyStr(re.compile(r"child:.+|child1:")): AnyStr(), - } - ), - } - }, - tasks=(), - interrupts=(), - ), StateSnapshot( values={"my_key": "hi my value here"}, next=("grandchild_2",), diff --git a/libs/langgraph/tests/test_large_cases_async.py b/libs/langgraph/tests/test_large_cases_async.py index 2b3a99c13..b144e89e7 100644 --- a/libs/langgraph/tests/test_large_cases_async.py +++ b/libs/langgraph/tests/test_large_cases_async.py @@ -3028,44 +3028,6 @@ async def test_doubly_nested_graph_state( c async for c in app.aget_state_history(outer_history[1].tasks[0].state) ] assert child_history == [ - StateSnapshot( - values={"my_key": "hi my value here and there"}, - next=(), - config={ - "configurable": { - "thread_id": "1", - "checkpoint_ns": AnyStr("child:"), - "checkpoint_id": AnyStr(), - "checkpoint_map": AnyDict( - {"": AnyStr(), AnyStr("child:"): AnyStr()} - ), - } - }, - metadata={ - "source": "loop", - "step": 1, - "parents": {"": AnyStr()}, - "thread_id": "1", - "langgraph_node": "child", - "langgraph_path": [PULL, AnyStr("child")], - "langgraph_step": 2, - "langgraph_triggers": ["branch:to:child"], - "langgraph_checkpoint_ns": AnyStr("child:"), - }, - created_at=AnyStr(), - parent_config={ - "configurable": { - "thread_id": "1", - "checkpoint_ns": AnyStr("child:"), - "checkpoint_id": AnyStr(), - "checkpoint_map": AnyDict( - {"": AnyStr(), AnyStr("child:"): AnyStr()} - ), - } - }, - tasks=(), - interrupts=(), - ), StateSnapshot( values={"my_key": "hi my value"}, next=("child_1",), @@ -3111,65 +3073,9 @@ async def test_doubly_nested_graph_state( ] # get grandchild graph history grandchild_history = [ - c async for c in app.aget_state_history(child_history[1].tasks[0].state) + c async for c in app.aget_state_history(child_history[0].tasks[0].state) ] assert grandchild_history == [ - StateSnapshot( - values={"my_key": "hi my value here and there"}, - next=(), - config={ - "configurable": { - "thread_id": "1", - "checkpoint_ns": AnyStr(), - "checkpoint_id": AnyStr(), - "checkpoint_map": AnyDict( - { - "": AnyStr(), - AnyStr("child:"): AnyStr(), - AnyStr(re.compile(r"child:.+|child1:")): AnyStr(), - } - ), - } - }, - metadata={ - "source": "loop", - "step": 2, - "parents": AnyDict( - { - "": AnyStr(), - AnyStr("child:"): AnyStr(), - } - ), - "thread_id": "1", - "langgraph_checkpoint_ns": AnyStr("child:"), - "langgraph_node": "child_1", - "langgraph_path": [ - PULL, - AnyStr("child_1"), - ], - "langgraph_step": 1, - "langgraph_triggers": [ - "branch:to:child_1", - ], - }, - created_at=AnyStr(), - parent_config={ - "configurable": { - "thread_id": "1", - "checkpoint_ns": AnyStr(), - "checkpoint_id": AnyStr(), - "checkpoint_map": AnyDict( - { - "": AnyStr(), - AnyStr("child:"): AnyStr(), - AnyStr(re.compile(r"child:.+|child1:")): AnyStr(), - } - ), - } - }, - tasks=(), - interrupts=(), - ), StateSnapshot( values={"my_key": "hi my value here"}, next=("grandchild_2",), diff --git a/libs/langgraph/tests/test_pregel.py b/libs/langgraph/tests/test_pregel.py index 0a1aad429..8434f4158 100644 --- a/libs/langgraph/tests/test_pregel.py +++ b/libs/langgraph/tests/test_pregel.py @@ -4626,11 +4626,14 @@ def test_debug_nested_subgraphs( return clean_config - for checkpoint_events, checkpoint_history in zip( - stream_ns.values(), history_ns.values() + for checkpoint_events, checkpoint_history, ns in zip( + stream_ns.values(), history_ns.values(), stream_ns.keys() ): if not checkpoint_during: checkpoint_events = checkpoint_events[-1:] + if ns: # Save no checkpoints for subgraphs when checkpoint_during=False + assert not checkpoint_history + continue assert len(checkpoint_events) == len(checkpoint_history) for stream, history in zip(checkpoint_events, checkpoint_history): assert stream["values"] == history.values diff --git a/libs/langgraph/tests/test_pregel_async.py b/libs/langgraph/tests/test_pregel_async.py index 7f3572a2b..db7c619c8 100644 --- a/libs/langgraph/tests/test_pregel_async.py +++ b/libs/langgraph/tests/test_pregel_async.py @@ -6052,11 +6052,14 @@ async def test_debug_nested_subgraphs( return clean_config - for checkpoint_events, checkpoint_history in zip( - stream_ns.values(), history_ns.values() + for checkpoint_events, checkpoint_history, ns in zip( + stream_ns.values(), history_ns.values(), stream_ns.keys() ): if not checkpoint_during: checkpoint_events = checkpoint_events[-1:] + if ns: # Save no checkpoints for subgraphs when checkpoint_during=False + assert not checkpoint_history + continue assert len(checkpoint_events) == len(checkpoint_history) for stream, history in zip(checkpoint_events, checkpoint_history): assert stream["values"] == history.values