Skip to content

Commit 08be70d

Browse files
committed
fix #3087
1 parent 1dee59f commit 08be70d

File tree

3 files changed

+60
-7
lines changed

3 files changed

+60
-7
lines changed

qiita_pet/handlers/api_proxy/processing.py

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# -----------------------------------------------------------------------------
88

99
from json import loads, dumps
10+
from collections import defaultdict
1011

1112
from qiita_db.user import User
1213
from qiita_db.artifact import Artifact
@@ -80,18 +81,30 @@ def list_options_handler_get_req(command_id, artifact_id=None):
8081
A dictionary containing the commands information
8182
{'status': str,
8283
'message': str,
83-
'options': list of dicts of {'id: str', 'name': str,
84-
'values': dict of {str: str}}}
84+
'options': list of dicts of {'id: str',
85+
'name': str,
86+
'values': dict of {str: str}},
87+
'req_options': dict,
88+
'opt_options': dict,
89+
'extra_artifacts': dict}
8590
"""
8691
def _helper_process_params(params):
8792
return dumps(
8893
{k: str(v).lower() for k, v in params.items()}, sort_keys=True)
8994

9095
command = Command(command_id)
91-
rparamers = command.required_parameters.keys()
96+
rparamers = []
97+
extra_atypes = []
98+
analysis = None
99+
for name, (type, atype) in command.required_parameters.items():
100+
rparamers.append(name)
101+
# [0] cause there is only one element
102+
extra_atypes.append(atype[0])
103+
92104
eparams = []
93105
if artifact_id is not None:
94106
artifact = Artifact(artifact_id)
107+
analysis = artifact.analysis
95108
for job in artifact.jobs(cmd=command):
96109
jstatus = job.status
97110
outputs = job.outputs if job.status == 'success' else None
@@ -104,14 +117,27 @@ def _helper_process_params(params):
104117
del params[k]
105118
eparams.append(_helper_process_params(params))
106119

120+
# removing this artifact from extra_artifacts
121+
if artifact.artifact_type in extra_atypes:
122+
extra_atypes.remove(artifact.artifact_type)
123+
124+
extra_artifacts = defaultdict(list)
125+
if analysis is not None:
126+
analysis_artifacts = analysis.artifacts
127+
for aa in analysis_artifacts:
128+
atype = aa.artifact_type
129+
if artifact_id != aa.id and atype in extra_atypes:
130+
extra_artifacts[atype].append((aa.id, aa.name))
131+
107132
options = [{'id': p.id, 'name': p.name, 'values': p.values}
108133
for p in command.default_parameter_sets
109134
if _helper_process_params(p.values) not in eparams]
110135
return {'status': 'success',
111136
'message': '',
112137
'options': options,
113138
'req_options': command.required_parameters,
114-
'opt_options': command.optional_parameters}
139+
'opt_options': command.optional_parameters,
140+
'extra_artifacts': extra_artifacts}
115141

116142

117143
def workflow_handler_post_req(user_id, command_id, params):

qiita_pet/handlers/api_proxy/tests/test_processing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,16 @@ def test_list_options_handler_get_req(self):
6868
'sortmerna_coverage': ['float', '0.97'],
6969
'sortmerna_e_value': ['float', '1'],
7070
'sortmerna_max_pos': ['integer', '10000'],
71-
'threads': ['integer', '1']}}
71+
'threads': ['integer', '1']},
72+
'extra_artifacts': {}}
7273
# First check that the keys are the same
7374
self.assertCountEqual(obs, exp)
7475
self.assertEqual(obs['status'], exp['status'])
7576
self.assertEqual(obs['message'], exp['message'])
7677
self.assertEqual(obs['options'], exp['options'])
7778
self.assertEqual(obs['req_options'], exp['req_options'])
7879
self.assertEqual(obs['opt_options'], exp['opt_options'])
80+
self.assertEqual(obs['extra_artifacts'], exp['extra_artifacts'])
7981

8082
def test_job_ajax_get_req(self):
8183
obs = job_ajax_get_req("063e553b-327c-4818-ab4a-adfe58e49860")

qiita_pet/static/js/networkVue.js

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,14 @@ Vue.component('processing-graph', {
555555
// Put first the required parameters
556556
$("#cmd-opts-div").append($('<h4>').text('Required parameters:'));
557557
var keys = Object.keys(data.req_options).sort(function(a, b){return a.localeCompare(b, 'en', {'sensitivity': 'base'});});
558+
559+
// adding extra artifacts to sel_artifacts_info so they are added to the GUI
560+
$.each(data.extra_artifacts, function(artifact_type, artifacts) {
561+
$.each(artifacts, function(index, adata) {
562+
sel_artifacts_info[adata[0]] = {'type': artifact_type, 'name': adata[1] + ' [' + adata[0] + ']'}
563+
});
564+
});
565+
558566
for (var i = 0; i < keys.length; i++) {
559567
var key = keys[i];
560568
vm.loadParameterGUI(key, data.req_options[key], sel_artifacts_info, $("#cmd-opts-div"));
@@ -748,7 +756,16 @@ Vue.component('processing-graph', {
748756
style: {
749757
'curve-style': 'bezier',
750758
'target-arrow-shape': 'triangle'
751-
}},
759+
}}, {
760+
selector: 'node.highlight',
761+
style: {
762+
'border-width': '5px'
763+
}}, {
764+
selector: 'edge.highlight',
765+
style: {
766+
'line-color': '#333',
767+
'target-arrow-color': '#333'
768+
}}
752769
];
753770
var panzoom_options = {
754771
zoomOnly: true,
@@ -787,9 +804,17 @@ Vue.component('processing-graph', {
787804
});
788805

789806
vm.network.on('tap', 'node', function (evt) {
790-
var data = evt.target.data();
807+
var target = evt.target;
808+
var data = target.data();
791809
var element_id = data.id;
792810

811+
// removing all highlight classes from network and highlighting the
812+
// element that was just selected
813+
vm.network.nodes().removeClass('highlight');
814+
vm.network.edges().removeClass('highlight');
815+
target.addClass('highlight');
816+
target.connectedEdges().addClass('highlight');
817+
793818
if (data.group === 'artifact') {
794819
vm.populateContentArtifact(element_id);
795820
} else if (data.group === 'deleting') {

0 commit comments

Comments
 (0)