Skip to content

Commit

Permalink
Merge pull request #15 from DARPA-ASKEM/graph-updates
Browse files Browse the repository at this point in the history
update graph to support new shape
  • Loading branch information
brandomr authored Oct 24, 2023
2 parents aaa9137 + e987e47 commit 80c0628
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
6 changes: 2 additions & 4 deletions dashboard/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ def custom_title(s):
FULL_CAPS = ['pdf', 'amr']

words = s.replace('_', ' ').split()
capitalized_words = [word.upper() if word in FULL_CAPS else word.title() for word in words]
return ' '.join(capitalized_words)


capitalized_words = [word.upper() if word.upper() in FULL_CAPS else word.title() for word in words]
return ' '.join(capitalized_words)
21 changes: 15 additions & 6 deletions dashboard/sections.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ def highlight_empty(val):

def render_scenario_viewer(scenarios):
st.write(f"### Scenario Viewer")
st.write(">**Note**: tasks marked as grey were not run due to an upstream failure.")
scenario_name = st.selectbox("Select a pipeline:", sorted(list(scenarios.keys())))
scenario = scenarios[scenario_name]

Expand All @@ -35,17 +34,23 @@ def render_scenario_viewer(scenarios):
status_color = 'gray'
graph.add_node(step_name, color=status_color)
shape = scenario["shape"]
for link in shape:
# Ensure both nodes exist before adding an edge
if link["from"] in graph.nodes and link["to"] in graph.nodes:
graph.add_edge(link["from"], link["to"])

nx.set_node_attributes(graph, "box", "shape")
pipeline = Network(notebook=False, directed=True)
pipeline.from_nx(graph)
for link in shape:
# Ensure both nodes exist before adding an edge
if link["from"] in graph.nodes and link["to"] in graph.nodes:
# If the link is soft, set it to be dashed and gray
if link["link_type"] == "soft":
pipeline.add_edge(link["from"], link["to"], color="gray", dashes=True)
else:
pipeline.add_edge(link["from"], link["to"])

pipeline.options = {
'layout': {
'hierarchical': {
'enabled': True,
'enabled': False,
'direction': 'LR',
'sortMethod': 'directed'
},
Expand All @@ -56,6 +61,10 @@ def render_scenario_viewer(scenarios):

st.write(f"**Scenario description**: `{scenario['description']}`")
st.write(f"**Total Time** `{round(total_time,2)}`")
st.write(">**Note**: tasks marked as grey were not run due to an upstream failure. " \
"Solid lines indicated a `hard` dependency between the tasks. "\
"Dashed lines indicate a `soft` dependency between the tasks meaning that "\
"if results are available from the upstream task, they will be used (but are not required).")
components.html(display, height=800, width=800)


Expand Down
5 changes: 4 additions & 1 deletion dashboard/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,8 @@ def select_report(ta):
if ta == "ta1":
for scenario in report["scenarios"].values():
scenario["steps"] = { custom_title(name): step for name, step in scenario["steps"].items()}
scenario["shape"] = [ {"from": custom_title(edge["from"]), "to": custom_title(edge["to"])} for edge in scenario["shape"]]
scenario["shape"] = [ {"from": custom_title(edge["from"]),
"to": custom_title(edge["to"]),
"link_type": edge.get("link_type", "hard")}
for edge in scenario["shape"]]
return report

0 comments on commit 80c0628

Please sign in to comment.