-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add default-workflow to future artifact - SPP (#3307)
* add default-workflow to future artifact - SPP * fix error * current_job -> starting_job * fix test * addressing @charles-cowart comments
- Loading branch information
Showing
3 changed files
with
102 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -411,6 +411,58 @@ def test_post(self): | |
sleep(0.5) | ||
self.assertIsNotNone(new_prep.artifact) | ||
|
||
def test_post_insert_artifact_and_add_default_processing(self): | ||
# now let's test adding an artifact + default processing to a new | ||
# preparation | ||
new_prep = qdb.metadata_template.prep_template.PrepTemplate.create( | ||
pd.DataFrame({'new_col': {'1.SKB1.640202': 1, | ||
'1.SKD3.640198': 2, | ||
'1.SKM4.640180': 3}}), | ||
qdb.study.Study(1), '16S') | ||
|
||
# creating the fastq files to be added | ||
fd, fp1 = mkstemp(suffix='_seqs.fastq') | ||
close(fd) | ||
self._clean_up_files.append(fp1) | ||
with open(fp1, 'w') as f: | ||
f.write("@HWI-ST753:189:D1385ACXX:1:1101:1214:1906 1:N:0:\n" | ||
"NACGTAGGGTGCAAGCGTTGTCCGGAATNA\n" | ||
"+\n" | ||
"#1=DDFFFHHHHHJJJJJJJJJJJJGII#0\n") | ||
|
||
fd, fp2 = mkstemp(suffix='_barcodes.fastq') | ||
close(fd) | ||
self._clean_up_files.append(fp2) | ||
with open(fp2, 'w') as f: | ||
f.write("@HWI-ST753:189:D1385ACXX:1:1101:1214:1906 2:N:0:\n" | ||
"NNNCNNNNNNNNN\n" | ||
"+\n" | ||
"#############\n") | ||
|
||
data = {'user_email': '[email protected]', | ||
'artifact_type': 'FASTQ', | ||
'prep_id': new_prep.id, | ||
'files': dumps([(fp1, 'raw_forward_seqs'), | ||
(fp2, 'raw_barcodes')]), | ||
'add_default_workflow': False} | ||
obs = self.post('/qiita_db/artifact/', headers=self.header, data=data) | ||
self.assertEqual(obs.code, 200) | ||
jid = loads(obs.body)['job_id'] | ||
# if we got to this point, then we should have a job and that job | ||
# should have children jobs (generated by the default workflow) | ||
job = qdb.processing_job.ProcessingJob(jid) | ||
children = [c.command.name for c in job.children] | ||
grandchildren = [gc.command.name for c in job.children | ||
for gc in c.children] | ||
self.assertEqual('Validate', job.command.name) | ||
self.assertEqual(['Split libraries FASTQ'], children) | ||
self.assertEqual(['Pick closed-reference OTUs'], grandchildren) | ||
|
||
# just to avoid any tentative issues, let's wait for the main job to | ||
# finish | ||
while job.status not in ('error', 'success'): | ||
sleep(0.5) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters