コード例 #1
0
 def test_run_creation_from_cwl(self, mock_get_pipeline):
     with open('runner/tests/run/pair-workflow.cwl', 'r') as f:
         app = json.load(f)
     with open('runner/tests/run/inputs.json', 'r') as f:
         inputs = json.load(f)
     mock_get_pipeline.return_value = app
     run = RunObject.from_cwl_definition(str(self.run.id), inputs)
     run.ready()
     for inp in run.inputs:
         if inp.name == 'pair':
             self.assertEqual(inp.db_value[0]['R1'][0]['location'],
                              'bid://%s' % str(self.file1.id))
             self.assertEqual(inp.value[0]['R1'][0]['path'],
                              self.file1.path)
             self.assertEqual(inp.db_value[0]['R2'][0]['location'],
                              'bid://%s' % str(self.file2.id))
             self.assertEqual(inp.value[0]['R2'][0]['path'],
                              self.file2.path)
             self.assertEqual(inp.db_value[1]['R1'][0]['location'],
                              'bid://%s' % str(self.file3.id))
             self.assertEqual(inp.value[1]['R1'][0]['path'],
                              self.file3.path)
             self.assertEqual(inp.db_value[1]['R2'][0]['location'],
                              'bid://%s' % str(self.file4.id))
             self.assertEqual(inp.value[1]['R2'][0]['path'],
                              self.file4.path)
コード例 #2
0
def create_run_task(run_id, inputs, output_directory=None):
    logger.info("Creating and validating Run for %s" % run_id)
    run = RunObject.from_cwl_definition(run_id, inputs)
    run.ready()
    RunObject.to_db(run)
    submit_job.delay(run_id, output_directory)
    logger.info("Run %s Ready" % run_id)
コード例 #3
0
 def test_run_to_db(self, mock_get_pipeline):
     with open('runner/tests/run/pair-workflow.cwl', 'r') as f:
         app = json.load(f)
     with open('runner/tests/run/inputs.json', 'r') as f:
         inputs = json.load(f)
     mock_get_pipeline.return_value = app
     run = RunObject.from_cwl_definition(str(self.run.id), inputs)
     run.to_db()
     try:
         run_obj = Run.objects.get(id=run.run_id)
     except Run.DoesNotExist as e:
         pass
     self.assertEqual(str(run_obj.id), run.run_id)
コード例 #4
0
def create_run_task(run_id, inputs, output_directory=None):
    logger.info("Creating and validating Run")
    try:
        run = RunObject.from_cwl_definition(run_id, inputs)
        run.ready()
    except RunCreateException as e:
        run = RunObject.from_db(run_id)
        run.fail({'details': str(e)})
        RunObject.to_db(run)
        logger.info("Run %s Failed" % run_id)
    else:
        RunObject.to_db(run)
        submit_job.delay(run_id, output_directory)
        logger.info("Run %s Ready" % run_id)
コード例 #5
0
    def test_multiple_failed_on_same_job(self, mock_get_pipeline):
        with open('runner/tests/run/pair-workflow.cwl', 'r') as f:
            app = json.load(f)
        with open('runner/tests/run/inputs.json', 'r') as f:
            inputs = json.load(f)

        mock_get_pipeline.return_value = app
        run = RunObject.from_cwl_definition(str(self.run.id), inputs)
        run.to_db()

        operator_run = OperatorRun.objects.first()
        operator_run.runs.add(run.run_obj)
        num_failed_runs = operator_run.num_failed_runs
        fail_job(run.run_id, {'details': 'Error has happened'})
        fail_job(run.run_id, {'details': 'Error has happened'})
        fail_job(run.run_id, {'details': 'Error has happened'})
        operator_run.refresh_from_db()
        self.assertEqual(operator_run.num_failed_runs, num_failed_runs + 1)
コード例 #6
0
 def test_run_complete_job(self, mock_get_pipeline):
     with open('runner/tests/run/pair-workflow.cwl', 'r') as f:
         app = json.load(f)
     with open('runner/tests/run/inputs.json', 'r') as f:
         inputs = json.load(f)
     mock_get_pipeline.return_value = app
     run = RunObject.from_cwl_definition(str(self.run.id), inputs)
     run.to_db()
     operator_run = OperatorRun.objects.first()
     operator_run.runs.add(run.run_obj)
     num_completed_runs = operator_run.num_completed_runs
     complete_job(run.run_id, self.outputs)
     operator_run.refresh_from_db()
     self.assertEqual(operator_run.num_completed_runs,
                      num_completed_runs + 1)
     run_obj = RunObject.from_db(run.run_id)
     file_obj = File.objects.filter(path=self.outputs['maf']['location'].
                                    replace('file://', '')).first()
     run_obj.to_db()
     for out in run_obj.outputs:
         if out.name == 'maf':
             self.assertEqual(out.value['location'],
                              self.outputs['maf']['location'])
             self.assertEqual(FileProcessor.get_bid_from_file(file_obj),
                              out.db_value['location'])
     port = Port.objects.filter(run_id=run_obj.run_id, name='bams').first()
     self.assertEqual(len(port.files.all()), 4)
     expected_result = (
         '/output/argos_pair_workflow/425194f6-a974-4c2f-995f-f27d7ba54ddc/outputs/test_1.rg.md.abra.printreads.bam',
         '/output/argos_pair_workflow/425194f6-a974-4c2f-995f-f27d7ba54ddc/outputs/test_1.rg.md.abra.printreads.bai',
         '/output/argos_pair_workflow/425194f6-a974-4c2f-995f-f27d7ba54ddc/outputs/test_2.rg.md.abra.printreads.bam',
         '/output/argos_pair_workflow/425194f6-a974-4c2f-995f-f27d7ba54ddc/outputs/test_2.rg.md.abra.printreads.bai'
     )
     self.assertTrue(port.files.all()[0].path in expected_result)
     self.assertTrue(port.files.all()[1].path in expected_result)
     self.assertTrue(port.files.all()[2].path in expected_result)
     self.assertTrue(port.files.all()[3].path in expected_result)