Esempio n. 1
0
    def test_save_with_inline_tools(self, tmpdir):
        wf = WorkflowGenerator()
        wf.load('tests/data/tools')
        wf.set_documentation('Counts words of a message via echo and wc')

        wfmessage = wf.add_input(wfmessage='string')
        echoed = wf.echo(message=wfmessage)
        wced = wf.wc(file2count=echoed)
        wf.add_outputs(wfcount=wced)

        wf_filename = tmpdir.join('echo-wc.cwl').strpath
        wf.save(wf_filename, inline=True)

        # Strip absolute paths from ids
        actual = load_yaml(wf_filename)
        expected_wf_filename = 'tests/data/workflows/echo-wc_inline.cwl'
        expected = load_yaml(expected_wf_filename)

        # Random id's will differ and that's ok, so just remove them
        def remove_random_ids(step):
            del(step['outputs'][0]['outputBinding']['glob'])
            del(step['stdout'])

        remove_random_ids(actual['steps']['wc']['run'])
        remove_random_ids(actual['steps']['echo']['run'])
        remove_random_ids(expected['steps']['wc']['run'])
        remove_random_ids(expected['steps']['echo']['run'])

        print('  actual:', actual)
        print('expected:', expected)
        assert actual == expected
Esempio n. 2
0
    def test_print_wf_absolute_paths(self, tmpdir):
        wf = setup_workflowgenerator(tmpdir)
        wf.load(steps_dir=tmpdir.join('tools').strpath)

        wf.set_documentation('Counts words of a message via echo and wc')

        wfmessage = wf.add_input(wfmessage='string')
        echoed = wf.echo(message=wfmessage)
        wced = wf.wc(file2count=echoed)
        wf.add_outputs(wfcount=wced)

        actual = wf.__str__()

        # make workflows contents relative to tests/data/tools directory
        actual = yaml.safe_load(actual)

        def fix_path(path):
            res = path.rsplit(os.sep, 2)
            res[0] = '..'
            return (os.sep).join(res)

        actual['steps']['echo']['run'] = \
            fix_path(actual['steps']['echo']['run'])
        actual['steps']['wc']['run'] = fix_path(actual['steps']['wc']['run'])

        expected_wf_filename = 'tests/data/workflows/echo-wc.cwl'
        expected = load_yaml(expected_wf_filename)

        print('  actual:', actual)
        print('expected:', expected)
        assert actual == expected
Esempio n. 3
0
    def test_save_with_workflow(self, tmpdir):
        wf = setup_workflowgenerator(tmpdir)
        wf.load(tmpdir.join('workflows').strpath)

        wfmessage = wf.add_input(wfmessage='string')
        wced = wf.echo_wc(wfmessage=wfmessage)
        wf.add_outputs(wfcount=wced)

        wf_filename = tmpdir.join('echo-wc.cwl').strpath
        wf.save(wf_filename, mode='rel')

        # make workflows contents relative to tests/data/tools directory
        actual = load_yaml(wf_filename)
        expected_wf_filename = 'tests/data/echo-wc.workflowstep.cwl'
        expected = load_yaml(expected_wf_filename)

        print('  actual:', actual)
        print('expected:', expected)
        assert actual == expected
Esempio n. 4
0
    def test_save_with_wd(self, tmpdir):
        wf = WorkflowGenerator(working_dir=tmpdir.join('wd').strpath)
        wf.load('tests/data/tools')

        wfmessage = wf.add_input(wfmessage='string')
        echoed = wf.echo(message=wfmessage)
        wced = wf.wc(file2count=echoed)
        wf.add_outputs(wfcount=wced)

        wf_filename = tmpdir.join('echo-wc.cwl').strpath
        wf.save(wf_filename, mode='wd')

        actual = load_yaml(wf_filename)
        expected_wf_filename = 'tests/data/workflows/echo-wc_wd.cwl'
        expected = load_yaml(expected_wf_filename)

        print('  actual:', actual)
        print('expected:', expected)
        assert actual == expected
Esempio n. 5
0
    def test_save_with_tools(self, tmpdir):
        wf = setup_workflowgenerator(tmpdir)
        wf.load(steps_dir=tmpdir.join('tools').strpath)
        wf.set_documentation('Counts words of a message via echo and wc')

        wfmessage = wf.add_input(wfmessage='string')
        echoed = wf.echo(message=wfmessage)
        wced = wf.wc(file2count=echoed)
        wf.add_outputs(wfcount=wced)

        wf_filename = tmpdir.join('workflows/echo-wc.cwl').strpath
        wf.save(wf_filename, mode='rel')

        # make workflows contents relative to tests/data/tools directory
        actual = load_yaml(wf_filename)
        expected_wf_filename = 'tests/data/workflows/echo-wc.cwl'
        expected = load_yaml(expected_wf_filename)

        print('  actual:', actual)
        print('expected:', expected)
        assert actual == expected
Esempio n. 6
0
    def test_save_with_scattered_step(self, tmpdir):
        wf = setup_workflowgenerator(tmpdir)
        wf.load(tmpdir.join('tools').strpath)

        msgs = wf.add_input(wfmessages='string[]')
        echoed = wf.echo(
            message=msgs,
            scatter='message',
            scatter_method='nested_crossproduct')
        wf.add_outputs(out_files=echoed)

        wf_filename = tmpdir.join('echo-scattered.cwl').strpath
        wf.save(wf_filename, mode='rel')

        # make workflows contents relative to tests/data/tools directory
        actual = load_yaml(wf_filename)
        expected_wf_filename = 'tests/data/echo.scattered.cwl'
        expected = load_yaml(expected_wf_filename)

        print('  actual:', actual)
        print('expected:', expected)
        assert actual == expected
Esempio n. 7
0
def test_load_yaml_packed(datafiles):
    cwl_file = str(datafiles.listdir()[0])

    assert {} == load_yaml(cwl_file)