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