Example #1
0
    def test_task_request_alignment_with_req(self):
        '''Tests multiple tasks with the same dependency and with request'''
        outdir = self.path_to('')

        # this task generates 0-10
        task0 = self.TaskWriteRoi2(outdir=outdir)
        task0_spec = {'task': task0, 'request': [daisy.Roi((2, ), (2, ))]}
        # request lies in block 1
        expected_block_ids = list(range(1, 2))

        ret = daisy.distribute([task0_spec])

        outfiles = glob.glob(os.path.join(outdir, '*.block'))
        block_ids = sorted(
            [int(path.split('/')[-1].split('.')[0]) for path in outfiles])

        self.assertTrue(ret)
        self.assertEqual(block_ids, expected_block_ids)
Example #2
0
    def test_single(self):
        '''Tests a vanilla task'''
        outdir = self.path_to('')

        # this task generates 0-10
        task = self.LeafTask(outdir=outdir)
        task_spec = {'task': task}

        expected_block_ids = list(range(10))

        ret = daisy.distribute([task_spec])

        outfiles = glob.glob(os.path.join(outdir, '*.block'))
        block_ids = sorted(
            [int(path.split('/')[-1].split('.')[0]) for path in outfiles])

        self.assertTrue(ret)
        self.assertEqual(block_ids, expected_block_ids)
Example #3
0
    def test_task_request_alignment_with_req5(self):
        '''Tests multiple tasks with the same dependency and with request'''
        outdir = self.path_to('')

        # this task generates 0-10
        task0 = self.TaskWriteRoi22(outdir=outdir)
        task0_spec = {'task': task0, 'request': [daisy.Roi((1, ), (6, ))]}
        # requesting 1, 2, 3, 4, 5, 6
        # is satisfied with 3 write blocks
        expected_write_begins = [1, 3, 5]

        ret = daisy.distribute([task0_spec])

        outfiles = glob.glob(os.path.join(outdir, '*.write_roi'))
        block_ids = sorted(
            [int(path.split('/')[-1].split('.')[0]) for path in outfiles])

        self.assertTrue(ret)
        self.assertEqual(block_ids, expected_write_begins)
Example #4
0
    def test_multi_with_request_same_overlapping(self):
        '''Tests multiple same task targets with overlapping requests'''
        outdir = self.path_to('')

        # this task generates 0-10
        task0 = self.LeafTask(outdir=outdir)

        task0_spec = {'task': task0, 'request': [daisy.Roi((3, ), (7, ))]}
        task1_spec = {'task': task0, 'request': [daisy.Roi((5, ), (5, ))]}
        expected_block_ids = list(range(3, 10))

        ret = daisy.distribute([task0_spec, task1_spec])

        outfiles = glob.glob(os.path.join(outdir, '*.block'))
        block_ids = sorted(
            [int(path.split('/')[-1].split('.')[0]) for path in outfiles])

        self.assertTrue(ret)
        self.assertEqual(block_ids, expected_block_ids)
Example #5
0
    def test_multi(self):
        '''Tests multiple different task targets'''
        outdir = self.path_to('')

        # this task generates 0-10
        task0 = self.LeafTask(outdir=outdir)
        expected_block_ids = list(range(0, 10))
        # this task generates 20-30
        task1 = self.LeafTaskAnother(outdir=outdir)
        expected_block_ids += list(range(20, 30))

        task0_spec = {'task': task0}
        task1_spec = {'task': task1}
        ret = daisy.distribute([task0_spec, task1_spec])

        outfiles = glob.glob(os.path.join(outdir, '*.block'))
        block_ids = sorted(
            [int(path.split('/')[-1].split('.')[0]) for path in outfiles])

        self.assertTrue(ret)
        self.assertEqual(block_ids, expected_block_ids)
Example #6
0
    def test_task_chain_multi_with_mixed_request(self):
        '''Tests multiple tasks with the same dependency and with request'''
        outdir = self.path_to('')

        # this task generates 0-10
        task0 = self.ParentTask(outdir=outdir)
        task0_spec = {'task': task0, 'request': [daisy.Roi((1, ), (2, ))]}
        # this task also generates 0-10
        task1 = self.ParentTaskAnother(outdir=outdir)
        task1_spec = {'task': task1}
        # their deps are merged
        expected_block_ids = list(range(0, 10))

        ret = daisy.distribute([task0_spec, task1_spec])

        outfiles = glob.glob(os.path.join(outdir, '*.block'))
        block_ids = sorted(
            [int(path.split('/')[-1].split('.')[0]) for path in outfiles])

        self.assertTrue(ret)
        self.assertEqual(block_ids, expected_block_ids)
Example #7
0
    def test_multi_with_request(self):
        '''Tests multiple different task targets with requests'''
        outdir = self.path_to('')

        # this task generates 0-10
        task0 = self.LeafTask(outdir=outdir)
        # this task generates 20-30
        task1 = self.LeafTaskAnother(outdir=outdir)

        task0_spec = {'task': task0, 'request': [daisy.Roi((3, ), (2, ))]}
        expected_block_ids = list(range(3, 5))
        task1_spec = {'task': task1, 'request': [daisy.Roi((27, ), (2, ))]}
        expected_block_ids += list(range(27, 29))

        ret = daisy.distribute([task0_spec, task1_spec])

        outfiles = glob.glob(os.path.join(outdir, '*.block'))
        block_ids = sorted(
            [int(path.split('/')[-1].split('.')[0]) for path in outfiles])

        self.assertTrue(ret)
        self.assertEqual(block_ids, expected_block_ids)