Skip to content

fixing issues from 2021.07 #3128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2021
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
31 changes: 15 additions & 16 deletions qiita_db/metadata_template/prep_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,25 +884,24 @@ def _get_predecessors(workflow, node):
job_params = qdb.software.Parameters.load(
cmd, values_dict=params)

if job_params in previous_jobs.values():
if params in previous_jobs.values():
for x, y in previous_jobs.items():
if job_params == y:
if params == y:
current_job = x
continue

if workflow is None:
PW = qdb.processing_job.ProcessingWorkflow
workflow = PW.from_scratch(user, job_params)
current_job = [j for j in workflow.graph.nodes()][0]
else:
if previous_job is None:
current_job = workflow.add(
job_params, req_params=req_params)
if workflow is None:
PW = qdb.processing_job.ProcessingWorkflow
workflow = PW.from_scratch(user, job_params)
current_job = [
j for j in workflow.graph.nodes()][0]
else:
current_job = workflow.add(
job_params, req_params=req_params,
connections={previous_job: connections})

previous_jobs[current_job] = job_params
if previous_job is None:
current_job = workflow.add(
job_params, req_params=req_params)
else:
current_job = workflow.add(
job_params, req_params=req_params,
connections={previous_job: connections})
previous_jobs[current_job] = params

return workflow
61 changes: 56 additions & 5 deletions qiita_db/metadata_template/test/test_prep_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -1346,13 +1346,64 @@ def test_artifact_setter(self):
self.filepaths, "FASTQ", prep_template=pt)
self.assertEqual(pt.artifact, artifact)

# here we can test that we can properly create a workflow
# here we can test that we can properly create a workflow but we are
# going to add lot more steps to make it more complex by adding a
# couple of new scenarios
# 1/2. adds a new path that should be kept separate all the way; this
# is to emulate what happens with different trimming (different
# default parameter) and deblur (same for each of the previous
# steps)
sql = """
INSERT INTO qiita.default_workflow_node (
default_workflow_id, default_parameter_set_id)
VALUES (1, 2), (1, 10);
INSERT INTO qiita.default_workflow_edge (
parent_id, child_id)
VALUES (7, 8);
INSERT INTO qiita.default_workflow_edge_connections (
default_workflow_edge_id, parent_output_id, child_input_id)
VALUES (4, 1, 3)"""
qdb.sql_connection.perform_as_transaction(sql)
# 2/2. adds a new path that should be kept together and then separate;
# this is to simulate what happens with MTX/WGS processing, one
# single QC step (together) and 2 separete profilers
sql = """
INSERT INTO qiita.default_parameter_set (
command_id, parameter_set_name, parameter_set)
VALUES (3, '100%',
('{"reference":1,"sortmerna_e_value":1,'
|| '"sortmerna_max_pos":'
|| '10000,"similarity":1.0,"sortmerna_coverage":1.00,'
|| '"threads":1}')::json);
INSERT INTO qiita.default_workflow_node (
default_workflow_id, default_parameter_set_id)
VALUES (1, 17);
INSERT INTO qiita.default_workflow_edge (
parent_id, child_id)
VALUES (7, 9);
INSERT INTO qiita.default_workflow_edge_connections (
default_workflow_edge_id, parent_output_id, child_input_id)
VALUES (5, 1, 3)
"""
qdb.sql_connection.perform_as_transaction(sql)
# Finally, we need to "activate" the merging scheme values of the
# commands so they are actually different:
# 31->'Pick closed-reference OTUs', 6->'Split libraries FASTQ'
sql = """
UPDATE qiita.command_parameter
SET check_biom_merge = true
WHERE command_parameter_id IN (31, 6)"""
qdb.sql_connection.perform_as_transaction(sql)

wk = pt.add_default_workflow(qdb.user.User('test@foo.bar'))
self.assertEqual(len(wk.graph.nodes), 2)
self.assertEqual(len(wk.graph.edges), 1)
self.assertEqual(
self.assertEqual(len(wk.graph.nodes), 5)
self.assertEqual(len(wk.graph.edges), 3)
self.assertCountEqual(
[x.command.name for x in wk.graph.nodes],
['Split libraries FASTQ', 'Pick closed-reference OTUs'])
# we should have 2 split libraries and 3 close reference
['Split libraries FASTQ', 'Split libraries FASTQ',
'Pick closed-reference OTUs', 'Pick closed-reference OTUs',
'Pick closed-reference OTUs'])

# now let's try to generate again and it should fail cause the jobs
# are alrady created
Expand Down
3 changes: 3 additions & 0 deletions qiita_pet/handlers/study_handlers/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class ListOptionsHandler(BaseHandler):
def get(self):
command_id = self.get_argument("command_id")
artifact_id = self.get_argument("artifact_id")
# if the artifact id has ':' it means that it's a job in construction
if ':' in artifact_id:
artifact_id = None
self.write(list_options_handler_get_req(command_id, artifact_id))


Expand Down
49 changes: 45 additions & 4 deletions qiita_pet/handlers/study_handlers/tests/test_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,54 @@


class TestListCommandsHandler(TestHandlerBase):
# TODO: Missing tests
pass
def test_get(self):
response = self.get('/study/process/commands/',
{'artifact_id': '8', 'include_analysis': 'true'})
self.assertEqual(response.code, 200)
exp = {'status': 'success', 'message': '', 'commands': [
{'id': 9, 'command': 'Summarize Taxa',
'output': [['taxa_summary', 'taxa_summary']]},
{'id': 10, 'command': 'Beta Diversity', 'output': [
['distance_matrix', 'beta_div_plots']]},
{'id': 11, 'command': 'Alpha Rarefaction', 'output': [
['rarefaction_curves', 'rarefaction_curves']]},
{'id': 12, 'command': 'Single Rarefaction', 'output': [
['rarefied_table', 'BIOM']]}]}

response = self.get('/study/process/commands/',
{'artifact_id': '3', 'include_analysis': 'false'})
self.assertEqual(response.code, 200)
exp = {'status': 'success', 'message': '', 'commands': [
{'id': 3, 'command': 'Pick closed-reference OTUs', 'output': [
['OTU table', 'BIOM']]}]}
self.assertEqual(loads(response.body), exp)


class TestListOptionsHandler(TestHandlerBase):
# TODO: Missing tests
pass
def test_get(self):
response = self.get('/study/process/commands/options/',
{'command_id': '3', 'artifact_id': '8'})
self.assertEqual(response.code, 200)
exp = {'status': 'success', 'message': '', 'options': [
{'id': 10, 'name': 'Defaults', 'values':
{'reference': 1, 'sortmerna_e_value': 1,
'sortmerna_max_pos': 10000, 'similarity': 0.97,
'sortmerna_coverage': 0.97, 'threads': 1}}],
'req_options': {'input_data': ['artifact', ['Demultiplexed']]},
'opt_options': {'reference': ['reference', '1'],
'sortmerna_e_value': ['float', '1'],
'sortmerna_max_pos': ['integer', '10000'],
'similarity': ['float', '0.97'],
'sortmerna_coverage': ['float', '0.97'],
'threads': ['integer', '1']}}
self.assertEqual(loads(response.body), exp)

# test that it works fine with a job_id:artifact_type
response = self.get('/study/process/commands/options/',
{'command_id': '3',
'artifact_id': 'job_id:artifact_type'})
self.assertEqual(response.code, 200)
self.assertEqual(loads(response.body), exp)


class TestJobAJAX(TestHandlerBase):
Expand Down
12 changes: 6 additions & 6 deletions qiita_pet/static/js/networkVue.js
Original file line number Diff line number Diff line change
Expand Up @@ -1145,8 +1145,8 @@ Vue.component('processing-graph', {
'<td>' + circle_statuses.join('') + '</td>' +
'<td rowspan="2" width="20px">&nbsp;</td>' +
'<td rowspan="2">&nbsp;&nbsp;&nbsp;</td>' +
'<td rowspan="2" align="center">' +
'<a class="btn btn-success form-control" id="add-default-workflow"><span class="glyphicon glyphicon-flash"></span> Add Default Workflow</a>' +
'<td rowspan="2" align="center" id="add-default-workflow">' +
'<a class="btn btn-success form-control" id="add-default-workflow-btn"><span class="glyphicon glyphicon-flash"></span> Add Default Workflow</a>' +
"<br/><br/><a href='https://qiita.ucsd.edu/workflows/' target='_blank'> "+
'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-exclamation-triangle" viewBox="0 0 16 16">' +
'<path d="M7.938 2.016A.13.13 0 0 1 8.002 2a.13.13 0 0 1 .063.016.146.146 0 0 1 .054.057l6.857 11.667c.036.06.035.124.002.183a.163.163 0 0 1-.054.06.116.116 0 0 ' +
Expand All @@ -1164,18 +1164,18 @@ Vue.component('processing-graph', {
'</table>';
$('#circle-explanation').html(full_text);

$('#add-default-workflow').on('click', function () {
$('#add-default-workflow-btn').on('click', function () {
$('#add-default-workflow').attr('disabled', true);
document.getElementById('add-default-workflow').innerHTML = 'Submitting!';
document.getElementById('add-default-workflow-btn').innerHTML = 'Submitting!';
$.post(vm.portal + '/study/process/workflow/default/', {prep_id: vm.elementId}, function(data) {
if (data['msg_error'] !== null){
$('#add-default-workflow').attr('disabled', false);
$('#add-default-workflow-btn').attr('disabled', false);
bootstrapAlert('Error generating workflow: ' + data['msg_error'].replace("\n", "<br/>"));
} else {
vm.updateGraph();
}
});
document.getElementById('add-default-workflow').innerHTML = ' Add Default Workflow';
document.getElementById('add-default-workflow-btn').innerHTML = ' Add Default Workflow';
});

// This call to udpate graph will take care of updating the jobs
Expand Down
4 changes: 3 additions & 1 deletion qiita_pet/templates/study_ajax/add_artifact.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
// Modify the submit action of the form to use AJAX
$("#create-artifact-form").submit(function(event){
event.preventDefault();
$('#add-files-btn').prop('disabled', true);
// Add the prep template as a parameter
$('<input>').attr({
type: 'hidden',
Expand Down Expand Up @@ -82,6 +83,7 @@
bootstrapAlert("Error: " + error_msg + " " + status, "danger");
}
});
$('#add-files-btn').prop('disabled', false);
});
});
</script>
Expand Down Expand Up @@ -111,7 +113,7 @@ <h4><i>No files attached to this preparation</i></h4>
</div>
<div class="row" id="submit-div" data-error-count="0" hidden>
<div class="col-md-12" style="margin-top: 5px;">
<input type="submit" class="btn btn-sm btn-success" onclick="this.disabled=true;" value="Add files">
<input type="submit" class="btn btn-sm btn-success" id="add-files-btn" value="Add files">
</div>
</div>
</form>