Refactor variable names and fix typo in code
This commit is contained in:
parent
1ce317c252
commit
74b723c4da
7 changed files with 36 additions and 28 deletions
|
|
@ -153,14 +153,14 @@ async def build_vertex(
|
|||
result_data_response.duration = duration
|
||||
result_data_response.timedelta = timedelta
|
||||
vertex.add_build_time(timedelta)
|
||||
inactive_vertices = None
|
||||
if graph.inactive_vertices:
|
||||
inactive_vertices = list(graph.inactive_vertices)
|
||||
graph.reset_inactive_vertices()
|
||||
inactivated_vertices = None
|
||||
if graph.inactivated_vertices:
|
||||
inactivated_vertices = list(graph.inactivated_vertices)
|
||||
graph.reset_inactivated_vertices()
|
||||
chat_service.set_cache(flow_id, graph)
|
||||
|
||||
build_response = VertexBuildResponse(
|
||||
inactive_vertices=inactive_vertices,
|
||||
inactivated_vertices=inactivated_vertices,
|
||||
valid=valid,
|
||||
params=params,
|
||||
id=vertex.id,
|
||||
|
|
|
|||
|
|
@ -158,7 +158,9 @@ class StreamData(BaseModel):
|
|||
data: dict
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"event: {self.event}\ndata: {orjson_dumps(self.data, indent_2=False)}\n\n"
|
||||
return (
|
||||
f"event: {self.event}\ndata: {orjson_dumps(self.data, indent_2=False)}\n\n"
|
||||
)
|
||||
|
||||
|
||||
class CustomComponentCode(BaseModel):
|
||||
|
|
@ -227,7 +229,7 @@ class ResultDataResponse(BaseModel):
|
|||
|
||||
class VertexBuildResponse(BaseModel):
|
||||
id: Optional[str] = None
|
||||
inactive_vertices: Optional[List[str]] = None
|
||||
inactivated_vertices: Optional[List[str]] = None
|
||||
valid: bool
|
||||
params: Optional[str]
|
||||
"""JSON string of the params."""
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class Graph:
|
|||
|
||||
self._vertices = self._graph_data["nodes"]
|
||||
self._edges = self._graph_data["edges"]
|
||||
self.inactive_vertices: set = set()
|
||||
self.inactivated_vertices: set = set()
|
||||
self.edges: List[ContractEdge] = []
|
||||
self.vertices: List[Vertex] = []
|
||||
self._build_graph()
|
||||
|
|
@ -137,7 +137,7 @@ class Graph:
|
|||
return {
|
||||
"runs": self._runs,
|
||||
"updates": self._updates,
|
||||
"inactive_vertices": self.inactive_vertices,
|
||||
"inactivated_vertices": self.inactivated_vertices,
|
||||
}
|
||||
|
||||
def build_graph_maps(self):
|
||||
|
|
@ -145,8 +145,8 @@ class Graph:
|
|||
self.in_degree_map = self.build_in_degree()
|
||||
self.parent_child_map = self.build_parent_child_map()
|
||||
|
||||
def reset_inactive_vertices(self):
|
||||
self.inactive_vertices = set()
|
||||
def reset_inactivated_vertices(self):
|
||||
self.inactivated_vertices = set()
|
||||
|
||||
def mark_all_vertices(self, state: str):
|
||||
"""Marks all vertices in the graph."""
|
||||
|
|
|
|||
|
|
@ -103,12 +103,12 @@ class Vertex:
|
|||
):
|
||||
# If the vertex is inactive and has only one in degree
|
||||
# it means that it is not a merge point in the graph
|
||||
self.graph.inactive_vertices.add(self.id)
|
||||
self.graph.inactivated_vertices.add(self.id)
|
||||
elif (
|
||||
self.state == VertexStates.ACTIVE
|
||||
and self.id in self.graph.inactive_vertices
|
||||
and self.id in self.graph.inactivated_vertices
|
||||
):
|
||||
self.graph.inactive_vertices.remove(self.id)
|
||||
self.graph.inactivated_vertices.remove(self.id)
|
||||
|
||||
@property
|
||||
def avg_build_time(self):
|
||||
|
|
|
|||
|
|
@ -219,8 +219,16 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
);
|
||||
},
|
||||
paste: (selection, position) => {
|
||||
if(selection.nodes.some((node) => node.data.type === "ChatInput") && checkChatInput(get().nodes)){
|
||||
useAlertStore.getState().setErrorData({title: "Error pasting components", list: ["You can only have one ChatInput component in the flow"]});
|
||||
if (
|
||||
selection.nodes.some((node) => node.data.type === "ChatInput") &&
|
||||
checkChatInput(get().nodes)
|
||||
) {
|
||||
useAlertStore
|
||||
.getState()
|
||||
.setErrorData({
|
||||
title: "Error pasting components",
|
||||
list: ["You can only have one ChatInput component in the flow"],
|
||||
});
|
||||
return;
|
||||
}
|
||||
let minimumX = Infinity;
|
||||
|
|
@ -440,8 +448,8 @@ const useFlowStore = create<FlowStoreType>((set, get) => ({
|
|||
status: BuildStatus,
|
||||
buildId: string
|
||||
) {
|
||||
if (vertexBuildData && vertexBuildData.inactive_vertices) {
|
||||
get().removeFromVerticesBuild(vertexBuildData.inactive_vertices);
|
||||
if (vertexBuildData && vertexBuildData.inactivated_vertices) {
|
||||
get().removeFromVerticesBuild(vertexBuildData.inactivated_vertices);
|
||||
}
|
||||
get().addDataToFlowPool(
|
||||
{ ...vertexBuildData, buildId },
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ export type VerticesOrderTypeAPI = {
|
|||
|
||||
export type VertexBuildTypeAPI = {
|
||||
id: string;
|
||||
inactive_vertices: Array<string> | null;
|
||||
inactivated_vertices: Array<string> | null;
|
||||
valid: boolean;
|
||||
params: string;
|
||||
data: VertexDataTypeAPI;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ function getInactiveVertexData(vertexId: string): VertexBuildTypeAPI {
|
|||
id: vertexId,
|
||||
data: inactiveData,
|
||||
params: "Inactive",
|
||||
inactive_vertices: null,
|
||||
inactivated_vertices: null,
|
||||
valid: false,
|
||||
timestamp: new Date().toISOString(),
|
||||
};
|
||||
|
|
@ -85,14 +85,12 @@ export async function updateVerticesOrder(
|
|||
}
|
||||
|
||||
const verticesIds = verticesLayers.flat();
|
||||
useFlowStore
|
||||
.getState()
|
||||
.updateVerticesBuild({
|
||||
verticesLayers,
|
||||
verticesIds,
|
||||
verticesOrder,
|
||||
runId,
|
||||
});
|
||||
useFlowStore.getState().updateVerticesBuild({
|
||||
verticesLayers,
|
||||
verticesIds,
|
||||
verticesOrder,
|
||||
runId,
|
||||
});
|
||||
resolve({ verticesLayers, verticesIds, verticesOrder, runId });
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue