feat(graph): make add_edge function start_key parameter in order #3575
+2
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem is solved?
When a graph is compiled twice, especially when the interrupt node exists, when the graph resumes running for the second time, when the add_edge function is called, for the start_key of the list type, if the order of the list is inconsistent with the first time, the end_key will never be reachable the second time
In what scenarios will there be problems?
When using fastapi or flask as a backend service, when there is an interrupted node, there will be problems when restoring the graph operation
When the
/run
interface is called for the first time,It will be interrupted at
node_interupt
,When the
/run
interface is called for the second time,It will resume running normally
But if the add_edge function is resumed for the second time, if the start_key order is different from the first time, such as
At this time, the flow_end node will be unreachable, graph End the run directly
This situation usually occurs when the node data for building the graph is not fixed, but the node data is obtained from the database. When the request hits different nodes of LVS, the order of start_key is likely to be inconsistent.
Improvement method
In the add_edge method, sort the start_key so that the start_key remains consistent each time the graph is built