Skip to content

Commit ae67124

Browse files
committed
tests(langgraph): skip when optional deps missing; chore(pyproject): add langgraph/langgraph_tools extras; relax extras to >= versions
1 parent 2d915d1 commit ae67124

File tree

4 files changed

+28
-34
lines changed

4 files changed

+28
-34
lines changed

pyproject.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,17 @@ langchain = [
134134
"langchain-core>=0.3.0",
135135
]
136136

137+
# Optional deps for LangGraph example/tests
138+
langgraph = [
139+
"langgraph>=0.6.7",
140+
"langchain-core>=0.3.75",
141+
]
142+
langgraph_tools = [
143+
"langgraph>=0.6.7",
144+
"langchain>=0.3.0",
145+
"langchain-fireworks>=0.3.0",
146+
]
147+
137148
[tool.pytest.ini_options]
138149
addopts = "-q"
139150
testpaths = [

tests/chinook/langgraph/graph.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@
99
from langgraph.graph import END, StateGraph
1010
from langchain_core.runnables import RunnableConfig
1111
from langchain_core.messages import BaseMessage, AIMessage
12-
except Exception as e: # pragma: no cover - import-time helpful error
13-
raise RuntimeError(
14-
"Missing required dependency for LangGraph example. Install langgraph and langchain-core."
15-
) from e
12+
except ImportError as e: # pragma: no cover - import-time helpful error
13+
# Gracefully skip this module's tests if optional deps are not installed
14+
import pytest
15+
16+
pytest.skip(
17+
"Missing optional deps for LangGraph example. Install extras: 'pip install -e .[langgraph]'",
18+
allow_module_level=True,
19+
)
1620

1721

1822
def build_graph() -> Any:

tests/chinook/langgraph/test_langgraph_chinook.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,6 @@
1212
import os
1313

1414

15-
LLM_JUDGE_PROMPT = (
16-
"Your job is to compare the response to the expected answer.\n"
17-
"The response will be a narrative report of the query results.\n"
18-
"If the response contains the same or well summarized information as the expected answer, return 1.0.\n"
19-
"If the response does not contain the same information or is missing information, return 0.0."
20-
)
21-
22-
23-
def to_langgraph_input(row: EvaluationRow) -> Dict[str, Any]:
24-
# Let the rollout processor handle EP→LC conversion by default; pass through
25-
return {"messages": row.messages or []}
26-
27-
28-
def apply_langgraph_result(row: EvaluationRow, result: Dict[str, Any]) -> EvaluationRow:
29-
# Rely on rollout processor defaults which convert LC→EP when possible
30-
maybe_msgs = result.get("messages") or []
31-
if isinstance(maybe_msgs, list) and all(isinstance(m, Message) for m in maybe_msgs):
32-
row.messages = maybe_msgs
33-
else:
34-
# Minimal fallback: stringify
35-
row.messages = [Message(role="assistant", content=str(m)) for m in maybe_msgs]
36-
return row
37-
38-
3915
def build_graph_kwargs(cp: CompletionParams) -> Dict[str, Any]:
4016
# Minimal runnable config mapping; not used by current graph but kept for API parity
4117
model = cp.get("model")
@@ -54,7 +30,6 @@ def build_graph_kwargs(cp: CompletionParams) -> Dict[str, Any]:
5430
input_key="messages",
5531
output_key="messages",
5632
),
57-
mode="pointwise",
5833
passed_threshold=1.0,
5934
)
6035
async def test_langgraph_simple_query(row: EvaluationRow) -> EvaluationRow:

tests/chinook/langgraph/tools_graph.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99
from langgraph.graph import END, START, StateGraph
1010
from langgraph.graph.message import add_messages
1111
from langgraph.prebuilt import ToolNode
12-
from langchain_core.messages import BaseMessage, AIMessage
12+
from langchain_core.messages import BaseMessage
1313
from langchain.chat_models import init_chat_model
1414
from langchain_core.tools import tool
1515
from typing_extensions import Annotated, TypedDict
16-
except Exception as e: # pragma: no cover - import-time helpful error
17-
raise RuntimeError(
18-
"Missing required dependency for LangGraph tools example. Install langgraph and langchain."
19-
) from e
16+
except ImportError as e: # pragma: no cover - import-time helpful error
17+
# Gracefully skip this module's tests if optional deps are not installed
18+
import pytest
19+
20+
pytest.skip(
21+
"Missing optional deps for LangGraph tools example. Install extras: 'pip install -e .[langgraph_tools]'",
22+
allow_module_level=True,
23+
)
2024

2125

2226
class State(TypedDict):

0 commit comments

Comments
 (0)