Skip to content

Commit

Permalink
create graph only once
Browse files Browse the repository at this point in the history
  • Loading branch information
antgonza committed Jan 11, 2024
1 parent aa86014 commit 33c9203
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions qiita_pet/handlers/analysis_handlers/base_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,26 @@ def analyisis_graph_handler_get_request(analysis_id, user):
edges = []
artifacts_being_deleted = []
wf_id = None
# Loop through all the initial artifacts of the analysis
for a in analysis.artifacts:
if a.processing_parameters is None:
g = a.descendants_with_jobs
nodes, edges, a_wf_id = get_network_nodes_edges(
g, full_access, nodes=nodes, edges=edges)

# nodes returns [node_type, node_name, element_id]; here we
# are looking for the node_type == artifact, and check by
# the element/artifact_id if it's being deleted
for a in nodes:
if (a[0] == 'artifact' and
Artifact(a[2]).being_deleted_by is not None):
artifacts_being_deleted.append(a[2])

if wf_id is None:
wf_id = a_wf_id
elif a_wf_id is not None and wf_id != a_wf_id:
# This should never happen, but worth having a useful message
raise ValueError('More than one workflow in a single analysis')
# Let's take the first artifact without processing_parameters (which makes
# it a root) and the rest of the work is done by descendants_with_jobs
a = [a for a in analysis.artifacts if a.processing_parameters is None][0]
g = a.descendants_with_jobs
nodes, edges, a_wf_id = get_network_nodes_edges(
g, full_access, nodes=nodes, edges=edges)

# nodes returns [node_type, node_name, element_id]; here we
# are looking for the node_type == artifact, and check by
# the element/artifact_id if it's being deleted
for a in nodes:
if (a[0] == 'artifact' and
Artifact(a[2]).being_deleted_by is not None):
artifacts_being_deleted.append(a[2])

if wf_id is None:
wf_id = a_wf_id
elif a_wf_id is not None and wf_id != a_wf_id:
# This should never happen, but worth having a useful message
raise ValueError('More than one workflow in a single analysis')

return {'edges': edges, 'nodes': nodes, 'workflow': wf_id,
'artifacts_being_deleted': artifacts_being_deleted}
Expand Down

0 comments on commit 33c9203

Please sign in to comment.