Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions qiita_pet/handlers/api_proxy/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# The full license is in the file LICENSE, distributed with this software.
# -----------------------------------------------------------------------------

from json import loads
from json import loads, dumps

from qiita_db.user import User
from qiita_db.artifact import Artifact
Expand Down Expand Up @@ -63,13 +63,16 @@ def list_commands_handler_get_req(id, exclude_analysis):
'commands': cmd_info}


def list_options_handler_get_req(command_id):
def list_options_handler_get_req(command_id, artifact_id=None):
"""Returns the available default parameters set for the given command

Parameters
----------
command_id : int
The command id
artifact_id : int, optional
The artifact id so to limit options based on how it has already been
processed

Returns
-------
Expand All @@ -80,9 +83,30 @@ def list_options_handler_get_req(command_id):
'options': list of dicts of {'id: str', 'name': str,
'values': dict of {str: str}}}
"""
def _helper_process_params(params):
return dumps(
{k: str(v).lower() for k, v in params.items()}, sort_keys=True)

command = Command(command_id)
rparamers = command.required_parameters.keys()
eparams = []
if artifact_id is not None:
artifact = Artifact(artifact_id)
for job in artifact.jobs(cmd=command):
jstatus = job.status
outputs = job.outputs if job.status == 'success' else None
# this ignore any jobs that weren't successful or are in
# construction, or the results have been deleted [outputs == {}]
if jstatus not in {'success', 'in_construction'} or outputs == {}:
continue
params = job.parameters.values.copy()
for k in rparamers:
del params[k]
eparams.append(_helper_process_params(params))

options = [{'id': p.id, 'name': p.name, 'values': p.values}
for p in command.default_parameter_sets]
for p in command.default_parameter_sets
if _helper_process_params(p.values) not in eparams]
return {'status': 'success',
'message': '',
'options': options,
Expand Down
3 changes: 2 additions & 1 deletion qiita_pet/handlers/study_handlers/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ class ListOptionsHandler(BaseHandler):
@authenticated
def get(self):
command_id = self.get_argument("command_id")
self.write(list_options_handler_get_req(command_id))
artifact_id = self.get_argument("artifact_id")
self.write(list_options_handler_get_req(command_id, artifact_id))


class WorkflowRunHandler(BaseHandler):
Expand Down
4 changes: 3 additions & 1 deletion qiita_pet/static/js/networkVue.js
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,9 @@ Vue.component('processing-graph', {
*/
loadCommandOptions: function(cmd_id, sel_artifacts_info) {
let vm = this;
$.get(vm.portal + '/study/process/commands/options/', {command_id: cmd_id})
// [0] cause there is only one
let artifact_id = Object.keys(sel_artifacts_info)[0];
$.get(vm.portal + '/study/process/commands/options/', {command_id: cmd_id, artifact_id: artifact_id})
.done(function(data){
// Put first the required parameters
$("#cmd-opts-div").append($('<h4>').text('Required parameters:'));
Expand Down