Spaces:
Runtime error
Runtime error
ugmSorcero
commited on
Commit
·
f65e26a
1
Parent(s):
6c3736e
Fixes linting
Browse files- interface/components.py +7 -4
- interface/config.py +1 -3
- interface/draw_pipelines.py +17 -6
interface/components.py
CHANGED
|
@@ -13,15 +13,18 @@ def component_select_pipeline(container):
|
|
| 13 |
if "Keyword Search" in pipeline_names
|
| 14 |
else 0,
|
| 15 |
)
|
| 16 |
-
if
|
|
|
|
|
|
|
|
|
|
| 17 |
(
|
| 18 |
search_pipeline,
|
| 19 |
index_pipeline,
|
| 20 |
) = pipeline_funcs[pipeline_names.index(selected_pipeline)]()
|
| 21 |
st.session_state["pipeline"] = {
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
}
|
| 26 |
|
| 27 |
|
|
|
|
| 13 |
if "Keyword Search" in pipeline_names
|
| 14 |
else 0,
|
| 15 |
)
|
| 16 |
+
if (
|
| 17 |
+
st.session_state["pipeline"] is None
|
| 18 |
+
or st.session_state["pipeline"]["name"] != selected_pipeline
|
| 19 |
+
):
|
| 20 |
(
|
| 21 |
search_pipeline,
|
| 22 |
index_pipeline,
|
| 23 |
) = pipeline_funcs[pipeline_names.index(selected_pipeline)]()
|
| 24 |
st.session_state["pipeline"] = {
|
| 25 |
+
"name": selected_pipeline,
|
| 26 |
+
"search_pipeline": search_pipeline,
|
| 27 |
+
"index_pipeline": index_pipeline,
|
| 28 |
}
|
| 29 |
|
| 30 |
|
interface/config.py
CHANGED
|
@@ -1,9 +1,7 @@
|
|
| 1 |
from interface.pages import page_landing_page, page_search, page_index
|
| 2 |
|
| 3 |
# Define default Session Variables over the whole session.
|
| 4 |
-
session_state_variables = {
|
| 5 |
-
"pipeline": None
|
| 6 |
-
}
|
| 7 |
|
| 8 |
# Define Pages for the demo
|
| 9 |
pages = {
|
|
|
|
| 1 |
from interface.pages import page_landing_page, page_search, page_index
|
| 2 |
|
| 3 |
# Define default Session Variables over the whole session.
|
| 4 |
+
session_state_variables = {"pipeline": None}
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# Define Pages for the demo
|
| 7 |
pages = {
|
interface/draw_pipelines.py
CHANGED
|
@@ -26,24 +26,35 @@ def get_pipeline_graph(pipeline):
|
|
| 26 |
fixed_pos_nodes = {}
|
| 27 |
for idx, (in_node, out_nodes) in enumerate(node_connections.items()):
|
| 28 |
if in_node not in fixed_pos_nodes:
|
| 29 |
-
fixed_pos_nodes[in_node] = np.array(
|
|
|
|
|
|
|
| 30 |
current_coordinate = (current_coordinate[0], current_coordinate[1] - 1)
|
| 31 |
# If more than 1 out node, then branch out in X coordinate
|
| 32 |
if len(out_nodes) > 1:
|
| 33 |
# if length is odd
|
| 34 |
if (len(out_nodes) % 2) != 0:
|
| 35 |
-
middle_node = out_nodes[round(len(out_nodes)/2, 0) - 1]
|
| 36 |
-
fixed_pos_nodes[middle_node] = np.array(
|
|
|
|
|
|
|
| 37 |
out_nodes = [n for n in out_nodes if n != middle_node]
|
| 38 |
-
correction_coordinate = -
|
| 39 |
for out_node in out_nodes:
|
| 40 |
-
fixed_pos_nodes[out_node] = np.array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
if correction_coordinate == -1:
|
| 42 |
correction_coordinate += 1
|
| 43 |
correction_coordinate += 1
|
| 44 |
current_coordinate = (current_coordinate[0], current_coordinate[1] - 1)
|
| 45 |
elif len(node_connections) - 1 == idx:
|
| 46 |
-
fixed_pos_nodes[out_nodes[0]] = np.array(
|
|
|
|
|
|
|
| 47 |
pos = nx.spring_layout(G, pos=fixed_pos_nodes, fixed=G.nodes(), seed=42)
|
| 48 |
for node in G.nodes:
|
| 49 |
G.nodes[node]["pos"] = list(pos[node])
|
|
|
|
| 26 |
fixed_pos_nodes = {}
|
| 27 |
for idx, (in_node, out_nodes) in enumerate(node_connections.items()):
|
| 28 |
if in_node not in fixed_pos_nodes:
|
| 29 |
+
fixed_pos_nodes[in_node] = np.array(
|
| 30 |
+
[current_coordinate[0], current_coordinate[1]]
|
| 31 |
+
)
|
| 32 |
current_coordinate = (current_coordinate[0], current_coordinate[1] - 1)
|
| 33 |
# If more than 1 out node, then branch out in X coordinate
|
| 34 |
if len(out_nodes) > 1:
|
| 35 |
# if length is odd
|
| 36 |
if (len(out_nodes) % 2) != 0:
|
| 37 |
+
middle_node = out_nodes[round(len(out_nodes) / 2, 0) - 1]
|
| 38 |
+
fixed_pos_nodes[middle_node] = np.array(
|
| 39 |
+
[current_coordinate[0], current_coordinate[1]]
|
| 40 |
+
)
|
| 41 |
out_nodes = [n for n in out_nodes if n != middle_node]
|
| 42 |
+
correction_coordinate = -len(out_nodes) / 2
|
| 43 |
for out_node in out_nodes:
|
| 44 |
+
fixed_pos_nodes[out_node] = np.array(
|
| 45 |
+
[
|
| 46 |
+
int(current_coordinate[0] + correction_coordinate),
|
| 47 |
+
int(current_coordinate[1]),
|
| 48 |
+
]
|
| 49 |
+
)
|
| 50 |
if correction_coordinate == -1:
|
| 51 |
correction_coordinate += 1
|
| 52 |
correction_coordinate += 1
|
| 53 |
current_coordinate = (current_coordinate[0], current_coordinate[1] - 1)
|
| 54 |
elif len(node_connections) - 1 == idx:
|
| 55 |
+
fixed_pos_nodes[out_nodes[0]] = np.array(
|
| 56 |
+
[current_coordinate[0], current_coordinate[1]]
|
| 57 |
+
)
|
| 58 |
pos = nx.spring_layout(G, pos=fixed_pos_nodes, fixed=G.nodes(), seed=42)
|
| 59 |
for node in G.nodes:
|
| 60 |
G.nodes[node]["pos"] = list(pos[node])
|