feat: add description on graph (#3371)
* feat: Add optional description attribute to Graph class and handle description in serialization. * refactor: Remove 'type' field from NodeData class. * refactor: Set default graph name if not provided. * fix: mypy error typeddict-item --------- Co-authored-by: italojohnny <italojohnnydosanjos@gmail.com>
This commit is contained in:
parent
26bc6bc645
commit
8de100eae3
2 changed files with 8 additions and 3 deletions
|
|
@ -48,6 +48,7 @@ class Graph:
|
|||
end: Optional["Component"] = None,
|
||||
flow_id: Optional[str] = None,
|
||||
flow_name: Optional[str] = None,
|
||||
description: Optional[str] = None,
|
||||
user_id: Optional[str] = None,
|
||||
log_config: Optional[LogConfig] = None,
|
||||
) -> None:
|
||||
|
|
@ -70,6 +71,7 @@ class Graph:
|
|||
self._updates = 0
|
||||
self.flow_id = flow_id
|
||||
self.flow_name = flow_name
|
||||
self.description = description
|
||||
self.user_id = user_id
|
||||
self._is_input_vertices: List[str] = []
|
||||
self._is_output_vertices: List[str] = []
|
||||
|
|
@ -170,10 +172,13 @@ class Graph:
|
|||
}
|
||||
if name:
|
||||
graph_dict["name"] = name
|
||||
elif name is None and self.flow_name:
|
||||
graph_dict["name"] = self.flow_name
|
||||
if description:
|
||||
graph_dict["description"] = description
|
||||
if endpoint_name:
|
||||
graph_dict["endpoint_name"] = endpoint_name
|
||||
elif description is None and self.description:
|
||||
graph_dict["description"] = self.description
|
||||
graph_dict["endpoint_name"] = str(endpoint_name)
|
||||
return graph_dict
|
||||
|
||||
def add_nodes_and_edges(self, nodes: List[NodeData], edges: List[EdgeData]):
|
||||
|
|
@ -841,6 +846,7 @@ class Graph:
|
|||
"edges": self.edges,
|
||||
"flow_id": self.flow_id,
|
||||
"flow_name": self.flow_name,
|
||||
"description": self.description,
|
||||
"user_id": self.user_id,
|
||||
"raw_graph_data": self.raw_graph_data,
|
||||
"top_level_vertices": self.top_level_vertices,
|
||||
|
|
|
|||
|
|
@ -18,4 +18,3 @@ class NodeData(TypedDict):
|
|||
positionAbsolute: NotRequired[Position]
|
||||
selected: NotRequired[bool]
|
||||
parent_node_id: NotRequired[str]
|
||||
type: str
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue