Add flow_id parameter to Graph.from_payload() method
This commit is contained in:
parent
dde6fd6d62
commit
6817651172
2 changed files with 5 additions and 3 deletions
|
|
@ -223,7 +223,7 @@ def build_and_cache_graph(
|
||||||
flow: Flow = session.get(Flow, flow_id)
|
flow: Flow = session.get(Flow, flow_id)
|
||||||
if not flow or not flow.data:
|
if not flow or not flow.data:
|
||||||
raise ValueError("Invalid flow ID")
|
raise ValueError("Invalid flow ID")
|
||||||
other_graph = Graph.from_payload(flow.data)
|
other_graph = Graph.from_payload(flow.data, flow_id)
|
||||||
if graph is None:
|
if graph is None:
|
||||||
graph = other_graph
|
graph = other_graph
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ class Graph:
|
||||||
self,
|
self,
|
||||||
nodes: List[Dict],
|
nodes: List[Dict],
|
||||||
edges: List[Dict[str, str]],
|
edges: List[Dict[str, str]],
|
||||||
|
flow_id: Optional[str] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.inputs = []
|
self.inputs = []
|
||||||
self.outputs = []
|
self.outputs = []
|
||||||
|
|
@ -34,6 +35,7 @@ class Graph:
|
||||||
self.raw_graph_data = {"nodes": nodes, "edges": edges}
|
self.raw_graph_data = {"nodes": nodes, "edges": edges}
|
||||||
self._runs = 0
|
self._runs = 0
|
||||||
self._updates = 0
|
self._updates = 0
|
||||||
|
self.flow_id = flow_id
|
||||||
|
|
||||||
self.top_level_vertices = []
|
self.top_level_vertices = []
|
||||||
for vertex in self._vertices:
|
for vertex in self._vertices:
|
||||||
|
|
@ -113,7 +115,7 @@ class Graph:
|
||||||
return predecessor_map, successor_map
|
return predecessor_map, successor_map
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_payload(cls, payload: Dict) -> "Graph":
|
def from_payload(cls, payload: Dict, flow_id: str) -> "Graph":
|
||||||
"""
|
"""
|
||||||
Creates a graph from a payload.
|
Creates a graph from a payload.
|
||||||
|
|
||||||
|
|
@ -128,7 +130,7 @@ class Graph:
|
||||||
try:
|
try:
|
||||||
vertices = payload["nodes"]
|
vertices = payload["nodes"]
|
||||||
edges = payload["edges"]
|
edges = payload["edges"]
|
||||||
return cls(vertices, edges)
|
return cls(vertices, edges, flow_id)
|
||||||
except KeyError as exc:
|
except KeyError as exc:
|
||||||
logger.exception(exc)
|
logger.exception(exc)
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue