Skip to content

Commit 5d969a7

Browse files
authored
Fixing minor issues (#3020)
* fixing minor issues * fix tests * some minor JS fixes * rm TRN in def release_validators(job) * fix self.step for validators * order LIBRARY_DESCRIPTOR and upper LIBRARY_STRATEGY
1 parent 7ee368e commit 5d969a7

File tree

9 files changed

+90
-88
lines changed

9 files changed

+90
-88
lines changed

qiita_db/processing_job.py

Lines changed: 63 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,75 +1007,74 @@ def release(self):
10071007

10081008
def release_validators(self):
10091009
"""Allows all the validator job spawned by this job to complete"""
1010-
with qdb.sql_connection.TRN:
1011-
if self.command.software.type not in ('artifact transformation',
1012-
'private'):
1013-
raise qdb.exceptions.QiitaDBOperationNotPermittedError(
1014-
"Only artifact transformation and private jobs can "
1015-
"release validators")
1016-
1017-
# Check if all the validators are completed. Validator jobs can be
1018-
# in two states when completed: 'waiting' in case of success
1019-
# or 'error' otherwise
1020-
1010+
if self.command.software.type not in ('artifact transformation',
1011+
'private'):
1012+
raise qdb.exceptions.QiitaDBOperationNotPermittedError(
1013+
"Only artifact transformation and private jobs can "
1014+
"release validators")
1015+
1016+
# Check if all the validators are completed. Validator jobs can be
1017+
# in two states when completed: 'waiting' in case of success
1018+
# or 'error' otherwise
1019+
1020+
validator_ids = ['%s [%s]' % (j.id, j.external_id)
1021+
for j in self.validator_jobs
1022+
if j.status not in ['waiting', 'error']]
1023+
1024+
# Active polling - wait until all validator jobs are completed
1025+
# TODO: As soon as we see one errored validator, we should kill
1026+
# the other jobs and exit early. Don't wait for all of the jobs
1027+
# to complete.
1028+
while validator_ids:
1029+
jids = ', '.join(validator_ids)
1030+
self.step = ("Validating outputs (%d remaining) via "
1031+
"job(s) %s" % (len(validator_ids), jids))
1032+
sleep(10)
10211033
validator_ids = ['%s [%s]' % (j.id, j.external_id)
10221034
for j in self.validator_jobs
10231035
if j.status not in ['waiting', 'error']]
10241036

1025-
# Active polling - wait until all validator jobs are completed
1026-
# TODO: As soon as we see one errored validator, we should kill
1027-
# the other jobs and exit early. Don't wait for all of the jobs
1028-
# to complete.
1029-
while validator_ids:
1030-
jids = ', '.join([j[0] for j in validator_ids])
1031-
self.step = ("Validating outputs (%d remaining) via "
1032-
"job(s) %s" % (len(validator_ids), jids))
1033-
sleep(10)
1034-
validator_ids = ['%s [%s]' % (j.id, j.external_id)
1035-
for j in self.validator_jobs
1036-
if j.status not in ['waiting', 'error']]
1037-
1038-
# Check if any of the validators errored
1039-
errored = [j for j in self.validator_jobs
1040-
if j.status == 'error']
1041-
if errored:
1042-
# At least one of the validators failed, Set the rest of the
1043-
# validators and the current job as failed
1044-
waiting = [j.id for j in self.validator_jobs
1045-
if j.status == 'waiting']
1046-
1047-
common_error = "\n".join(
1048-
["Validator %s error message: %s" % (j.id, j.log.msg)
1049-
for j in errored])
1050-
1051-
val_error = "%d sister validator jobs failed: %s" % (
1052-
len(errored), common_error)
1053-
for j in waiting:
1054-
ProcessingJob(j)._set_error(val_error)
1055-
1056-
self._set_error('%d validator jobs failed: %s'
1057-
% (len(errored), common_error))
1058-
else:
1059-
mapping = {}
1060-
# Loop through all validator jobs and release them, allowing
1061-
# to create the artifacts. Note that if any artifact creation
1062-
# fails, the rollback operation will make sure that the
1063-
# previously created artifacts are not in there
1064-
for vjob in self.validator_jobs:
1065-
mapping.update(vjob.release())
1066-
1067-
if mapping:
1068-
sql = """INSERT INTO
1069-
qiita.artifact_output_processing_job
1070-
(artifact_id, processing_job_id,
1071-
command_output_id)
1072-
VALUES (%s, %s, %s)"""
1073-
sql_args = [[aid, self.id, outid]
1074-
for outid, aid in mapping.items()]
1037+
# Check if any of the validators errored
1038+
errored = [j for j in self.validator_jobs
1039+
if j.status == 'error']
1040+
if errored:
1041+
# At least one of the validators failed, Set the rest of the
1042+
# validators and the current job as failed
1043+
waiting = [j.id for j in self.validator_jobs
1044+
if j.status == 'waiting']
1045+
1046+
common_error = "\n".join(
1047+
["Validator %s error message: %s" % (j.id, j.log.msg)
1048+
for j in errored])
1049+
1050+
val_error = "%d sister validator jobs failed: %s" % (
1051+
len(errored), common_error)
1052+
for j in waiting:
1053+
ProcessingJob(j)._set_error(val_error)
1054+
1055+
self._set_error('%d validator jobs failed: %s'
1056+
% (len(errored), common_error))
1057+
else:
1058+
mapping = {}
1059+
# Loop through all validator jobs and release them, allowing
1060+
# to create the artifacts. Note that if any artifact creation
1061+
# fails, the rollback operation will make sure that the
1062+
# previously created artifacts are not in there
1063+
for vjob in self.validator_jobs:
1064+
mapping.update(vjob.release())
1065+
1066+
if mapping:
1067+
sql = """INSERT INTO
1068+
qiita.artifact_output_processing_job
1069+
(artifact_id, processing_job_id,
1070+
command_output_id)
1071+
VALUES (%s, %s, %s)"""
1072+
sql_args = [[aid, self.id, outid]
1073+
for outid, aid in mapping.items()]
1074+
with qdb.sql_connection.TRN:
10751075
qdb.sql_connection.TRN.add(sql, sql_args, many=True)
1076-
1077-
self._update_and_launch_children(mapping)
1078-
self._set_status('success')
1076+
self._update_and_launch_children(mapping)
1077+
self._set_status('success')
10791078

10801079
def _complete_artifact_definition(self, artifact_data):
10811080
""""Performs the needed steps to complete an artifact definition job

qiita_pet/handlers/api_proxy/processing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@ def job_ajax_get_req(job_id):
240240
job_error = job.log.msg if job.log is not None else None
241241
return {'status': 'success',
242242
'message': '',
243-
'job_id': '%s [%s]' % (job.id, job.external_id),
243+
'job_id': job.id,
244+
'job_external_id': job.external_id,
244245
'job_status': job_status,
245246
'job_step': job.step,
246247
'job_parameters': job.parameters.values,

qiita_pet/handlers/api_proxy/tests/test_processing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ def test_job_ajax_get_req(self):
8282
exp = {
8383
'status': 'success',
8484
'message': '',
85-
'job_id': "063e553b-327c-4818-ab4a-adfe58e49860 [Not Available]",
85+
'job_id': "063e553b-327c-4818-ab4a-adfe58e49860",
86+
'job_external_id': "Not Available",
8687
'job_status': "queued",
8788
'job_step': None,
8889
'job_error': None,

qiita_pet/handlers/study_handlers/tests/test_processing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def test_get(self):
3232
exp = {
3333
'status': 'success',
3434
'message': '',
35-
'job_id': "063e553b-327c-4818-ab4a-adfe58e49860 [Not Available]",
35+
'job_id': "063e553b-327c-4818-ab4a-adfe58e49860",
36+
'job_external_id': 'Not Available',
3637
'job_status': "queued",
3738
'job_step': None,
3839
'job_error': None,

qiita_pet/static/js/networkVue.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,11 @@ Vue.component('processing-graph', {
349349
vm.updateGraph();
350350
})
351351
.fail(function(object, status, error_msg) {
352-
$('#run-btn').attr('disabled', false);
353-
$('#run-btn').innerHTML = '<span class="glyphicon glyphicon-play"></span> Run';
354352
bootstrapAlert("Error submitting workflow: " + object.statusText, "danger");
355353
});
354+
// return button to regular state
355+
$('#run-btn').attr('disabled', false);
356+
$('#run-btn').html('<span class="glyphicon glyphicon-play"></span> Run');
356357
},
357358

358359
/**
@@ -371,7 +372,7 @@ Vue.component('processing-graph', {
371372
$("#processing-results").empty();
372373

373374
// Create the header of the page
374-
var h = $("<h3>").text('Job ' + data['job_id'] + ' ').appendTo("#processing-results");
375+
var h = $("<h3>").text('Job ' + data['job_id'] + ' [' + data['job_external_id'] + '] ').appendTo("#processing-results");
375376

376377
// Only add the delete job button if the job is "in_construction"
377378
// or "error"

qiita_pet/templates/software.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ <h5>
1919
<a href="https://qiita.ucsd.edu/static/doc/html/processingdata/processing-recommendations.html">Here</a> you will find our current processing recommendations.
2020
</h5>
2121

22-
<table class="table-bordered" width="50%">
22+
<table class="table-bordered" width="90%">
2323
<thead>
2424
<tr>
25-
<th>Plugin</th>
26-
<th>Commands</th>
25+
<th width="20%">Plugin</th>
26+
<th width="80%">Commands</th>
2727
</tr>
2828
</thead>
2929
<tbody>
@@ -45,8 +45,8 @@ <h5>
4545
<table class="display table-bordered table-hover" width="100%">
4646
<thead>
4747
<tr>
48-
<th>Command Name</th>
49-
<th>Resource Allocation</th>
48+
<th width="55%">Command Name</th>
49+
<th width="44%">Resource Allocation</th>
5050
</tr>
5151
</thead>
5252
<tbody>

qiita_ware/ebi.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,9 @@ def generate_experiment_xml(self, samples=None):
526526
library_name = ET.SubElement(library_descriptor, 'LIBRARY_NAME')
527527
library_name.text = self._get_library_name(sample_name)
528528

529+
lg = ET.SubElement(library_descriptor, 'LIBRARY_STRATEGY')
530+
lg.text = escape(clean_whitespace(library_strategy.upper()))
531+
529532
# hardcoding some values,
530533
# see https://github.com/biocore/qiita/issues/1485
531534
library_source = ET.SubElement(library_descriptor,
@@ -546,9 +549,6 @@ def generate_experiment_xml(self, samples=None):
546549
lcp.text = escape(clean_whitespace(
547550
sample_prep.pop('library_construction_protocol')))
548551

549-
lg = ET.SubElement(library_descriptor, 'LIBRARY_STRATEGY')
550-
lg.text = library_strategy
551-
552552
self._generate_spot_descriptor(design, platform)
553553

554554
platform_element = ET.SubElement(experiment, 'PLATFORM')

qiita_ware/private_plugin.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,9 @@ def release_validators(job):
7575
job : qiita_db.processing_job.ProcessingJob
7676
The processing job with the information of the parent job
7777
"""
78-
with qdb.sql_connection.TRN:
79-
qdb.processing_job.ProcessingJob(
80-
job.parameters.values['job']).release_validators()
81-
job._set_status('success')
78+
qdb.processing_job.ProcessingJob(
79+
job.parameters.values['job']).release_validators()
80+
job._set_status('success')
8281

8382

8483
def submit_to_VAMPS(job):

qiita_ware/test/test_ebi.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ def test_generate_experiment_xml(self):
532532

533533
# changing investigation_type to test user defined terms, first let's
534534
# create a new term
535-
new_term = 'Ultimate Term'
535+
new_term = 'ULTIMATE TERM'
536536
ena_ontology = Ontology(convert_to_id('ENA', 'ontology'))
537537
ena_ontology.add_user_defined_term(new_term)
538538
# set the preparation with the new term
@@ -1359,12 +1359,12 @@ def test_parse_EBI_reply(self):
13591359
%(study_id)s.Sample1" />
13601360
<LIBRARY_DESCRIPTOR>
13611361
<LIBRARY_NAME>%(study_id)s.Sample1</LIBRARY_NAME>
1362+
<LIBRARY_STRATEGY>METAGENOMICS</LIBRARY_STRATEGY>
13621363
<LIBRARY_SOURCE>METAGENOMIC</LIBRARY_SOURCE>
13631364
<LIBRARY_SELECTION>PCR</LIBRARY_SELECTION>
13641365
<LIBRARY_LAYOUT><SINGLE /></LIBRARY_LAYOUT>
13651366
<LIBRARY_CONSTRUCTION_PROTOCOL>Protocol ABC
13661367
</LIBRARY_CONSTRUCTION_PROTOCOL>
1367-
<LIBRARY_STRATEGY>Metagenomics</LIBRARY_STRATEGY>
13681368
</LIBRARY_DESCRIPTOR>
13691369
</DESIGN>
13701370
<PLATFORM>
@@ -1394,12 +1394,12 @@ def test_parse_EBI_reply(self):
13941394
%(study_id)s.Sample2" />
13951395
<LIBRARY_DESCRIPTOR>
13961396
<LIBRARY_NAME>%(study_id)s.Sample2</LIBRARY_NAME>
1397+
<LIBRARY_STRATEGY>METAGENOMICS</LIBRARY_STRATEGY>
13971398
<LIBRARY_SOURCE>METAGENOMIC</LIBRARY_SOURCE>
13981399
<LIBRARY_SELECTION>PCR</LIBRARY_SELECTION>
13991400
<LIBRARY_LAYOUT><SINGLE /></LIBRARY_LAYOUT>
14001401
<LIBRARY_CONSTRUCTION_PROTOCOL>Protocol ABC
14011402
</LIBRARY_CONSTRUCTION_PROTOCOL>
1402-
<LIBRARY_STRATEGY>Metagenomics</LIBRARY_STRATEGY>
14031403
</LIBRARY_DESCRIPTOR>
14041404
</DESIGN>
14051405
<PLATFORM>
@@ -1429,12 +1429,12 @@ def test_parse_EBI_reply(self):
14291429
%(study_id)s.Sample3" />
14301430
<LIBRARY_DESCRIPTOR>
14311431
<LIBRARY_NAME>%(study_id)s.Sample3</LIBRARY_NAME>
1432+
<LIBRARY_STRATEGY>METAGENOMICS</LIBRARY_STRATEGY>
14321433
<LIBRARY_SOURCE>METAGENOMIC</LIBRARY_SOURCE>
14331434
<LIBRARY_SELECTION>PCR</LIBRARY_SELECTION>
14341435
<LIBRARY_LAYOUT><SINGLE /></LIBRARY_LAYOUT>
14351436
<LIBRARY_CONSTRUCTION_PROTOCOL>Protocol ABC
14361437
</LIBRARY_CONSTRUCTION_PROTOCOL>
1437-
<LIBRARY_STRATEGY>Metagenomics</LIBRARY_STRATEGY>
14381438
</LIBRARY_DESCRIPTOR>
14391439
</DESIGN>
14401440
<PLATFORM>
@@ -1470,6 +1470,7 @@ def test_parse_EBI_reply(self):
14701470
<SAMPLE_DESCRIPTOR accession="ERS000008" />
14711471
<LIBRARY_DESCRIPTOR>
14721472
<LIBRARY_NAME>1.SKB2.640194</LIBRARY_NAME>
1473+
<LIBRARY_STRATEGY>METAGENOMICS</LIBRARY_STRATEGY>
14731474
<LIBRARY_SOURCE>METAGENOMIC</LIBRARY_SOURCE>
14741475
<LIBRARY_SELECTION>PCR</LIBRARY_SELECTION>
14751476
<LIBRARY_LAYOUT><SINGLE /></LIBRARY_LAYOUT>
@@ -1484,7 +1485,6 @@ def test_parse_EBI_reply(self):
14841485
multiplexing of up to 1,500 samples per lane, and both PCR primers contain \
14851486
sequencer adapter regions.
14861487
</LIBRARY_CONSTRUCTION_PROTOCOL>
1487-
<LIBRARY_STRATEGY>Metagenomics</LIBRARY_STRATEGY>
14881488
</LIBRARY_DESCRIPTOR>
14891489
</DESIGN>
14901490
<PLATFORM>
@@ -1559,6 +1559,7 @@ def test_parse_EBI_reply(self):
15591559
<SAMPLE_DESCRIPTOR accession="ERS000024" />
15601560
<LIBRARY_DESCRIPTOR>
15611561
<LIBRARY_NAME>1.SKB3.640195</LIBRARY_NAME>
1562+
<LIBRARY_STRATEGY>METAGENOMICS</LIBRARY_STRATEGY>
15621563
<LIBRARY_SOURCE>METAGENOMIC</LIBRARY_SOURCE>
15631564
<LIBRARY_SELECTION>PCR</LIBRARY_SELECTION>
15641565
<LIBRARY_LAYOUT><SINGLE /></LIBRARY_LAYOUT>
@@ -1573,7 +1574,6 @@ def test_parse_EBI_reply(self):
15731574
multiplexing of up to 1,500 samples per lane, and both PCR primers contain \
15741575
sequencer adapter regions.
15751576
</LIBRARY_CONSTRUCTION_PROTOCOL>
1576-
<LIBRARY_STRATEGY>Metagenomics</LIBRARY_STRATEGY>
15771577
</LIBRARY_DESCRIPTOR>
15781578
</DESIGN>
15791579
<PLATFORM>

0 commit comments

Comments
 (0)