-
Notifications
You must be signed in to change notification settings - Fork 878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot draw graph w/ xray=True when graph contains a subgraph w/ edges targeting the subgraph entry point #593
Comments
Ran sys info in the wrong env. Here are actual values for stacktrace and env info:
{
"name": "AttributeError",
"message": "'NoneType' object has no attribute 'id'",
"stack": "---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[2], line 58
54 for event in app.stream({'messages': [('human', 'start')]}, stream_mode='values'):
55 print(event)
---> 58 display(Image(app.get_graph(xray=True).draw_mermaid_png())) # this fails
File ~/.pyenv/versions/3.11.1/envs/math/lib/python3.11/site-packages/langgraph/graph/graph.py:470, in CompiledGraph.get_graph(self, config, xray)
468 end_nodes[key] = n
469 for start, end in sorted(self.builder._all_edges):
--> 470 graph.add_edge(start_nodes[start], end_nodes[end])
471 for start, branches in self.builder.branches.items():
472 default_ends = {
473 **{k: k for k in self.builder.nodes if k != start},
474 END: END,
475 }
File ~/.pyenv/versions/3.11.1/envs/math/lib/python3.11/site-packages/langchain_core/runnables/graph.py:260, in Graph.add_edge(self, source, target, data, conditional)
252 def add_edge(
253 self,
254 source: Node,
(...)
257 conditional: bool = False,
258 ) -> Edge:
259 \"\"\"Add an edge to the graph and return it.\"\"\"
--> 260 if source.id not in self.nodes:
261 raise ValueError(f\"Source node {source.id} not in graph\")
262 if target.id not in self.nodes:
AttributeError: 'NoneType' object has no attribute 'id'"
} |
Can reproduce - thanks for raising |
Is there any update on this? I'm still encountering this issue with my graphs |
My workaround is to remove the following 2 lines (link):
In the above case, the subgraph cannot find first node / last node after they are trimmed. |
Getting the same error when having a conditional edge in my subgraph while the whole graph runs just fine! |
Same error here, the sub-graph and graph runs ok, but the graphic can not be generated using "xray" parameter. Error message is the same: AttributeError: 'NoneType' object has no attribute 'id'. |
@nfcampos Mind giving this issue a bit of a priority boost? Almost every complex graph have this problem. |
same problem here |
Hi, can you confirm this issue still occurs in the latest version? 0.2.4 |
I've added the snippet above as a test case and can confirm this is fixed, closing, thanks for reporting! |
Checked other resources
Example Code
-->
Error Message and Stack Trace (if applicable)
Description
I'm trying to draw a graph which contains a subgraph as a node.
The subgraph has edges which target the entry node, which seems to be the problem in
get_graph(xray=True)
I expect to see an image of the graph.
Instead I get an exception.
System Info
see below
The text was updated successfully, but these errors were encountered: