Пример #1
0
    def testAnalyzeOutputFrom(self):
        '''Test extracting of from=value option from input'''
        script = SoS_Script('''
[A_1]
input:  output_from('B')

[A_2]
input: something_unknown, sos_groups(output_from(['C1', 'C2']), by=2), group_by=1
''')
        wf = script.workflow('A')
        for section in wf.sections:
            res = analyze_section(section)
            if section.names[0][1] == 1:
                self.assertEqual(res['step_depends'], sos_targets(sos_step('B')))
            if section.names[0][1] == 2:
                self.assertTrue(res['step_depends'] == sos_targets(sos_step('C1'), sos_step('C2')))
Пример #2
0
def test_analyze_output_from():
    '''Test extracting of from=value option from input'''
    script = SoS_Script('''
[A_1]
input:  output_from('B')

[A_2]
input: something_unknown, sos_groups(output_from(['C1', 'C2']), by=2), group_by=1
''')
    wf = script.workflow('A')
    Base_Executor(wf)
    for section in wf.sections:
        res = analyze_section(section, analysis_type='forward')
        if section.names[0][1] == 1:
            assert res['step_depends'] == sos_targets(sos_step('B'))
        if section.names[0][1] == 2:
            assert res['step_depends'] == sos_targets(sos_step('C1'),
                                                      sos_step('C2'))
Пример #3
0
    def testAnalyzeFromOption(self):
        '''Test extracting of from=value option from input'''
        script = SoS_Script('''
[A_1]
input:  from_steps='B'

[A_2]
input: something_unknown, from_steps=['B', 'C2'], group_by=1
''')
        wf = script.workflow('A')
        for section in wf.sections:
            res = analyze_section(section)
            if section.names[0][1] == '1':
                self.assertEqual(res['step_depends'],
                                 sos_targets(sos_step('B')))
            if section.names[0][1] == '2':
                self.assertTrue(res['step_depends'] == sos_targets(
                    sos_step('B'), sos_step('C2')))
Пример #4
0
    def testAnalyzeSection(self):
        '''Test analysis of sections (statically)'''
        script = SoS_Script('''
g1 = 'a'
g2 = 1
parameter: p1 = 5
parameter: infiles = 'a.txt'

[A_1: shared='b']
b = p1 + 2
input:  infiles
output: None
c = 5

[A_2]
b = [1, 2, 3]
input: for_each='b'
depends: 'some.txt', executable('ls')
import time
import random

r = random.randint(1, 5)
time.sleep(r)

[A_3]
input: None
print(p1)

[A_4]
input: None
task:
python: expand=True
   print(f'{output}')

[A_5]
task:
   print(f'{_output}')
''')
        wf = script.workflow('A')
        for section in wf.sections:
            res = analyze_section(section)
            if section.names[0][1] == '1':
                self.assertTrue(res['step_input'].undetermined())
                self.assertEqual(res['step_depends'], sos_targets())
                self.assertEqual(res['step_output'], sos_targets())
                self.assertEqual(res['environ_vars'], {'b', 'p1', 'infiles'})
                self.assertEqual(res['signature_vars'], {'c'})
                self.assertEqual(res['changed_vars'], {'b'})
            elif section.names[0][1] == '2':
                self.assertEqual(res['step_input'], sos_targets())
                self.assertEqual(res['step_depends'], sos_targets(
                    'some.txt', executable('ls')))
                self.assertTrue(res['step_output'].unspecified())
                # for_each will not be used for DAG
                self.assertEqual(res['environ_vars'], {
                                 'b', 'for_each', 'executable'})
                self.assertEqual(res['signature_vars'], {
                                 'r', 'time', 'random'})
                self.assertEqual(res['changed_vars'], set())
            elif section.names[0][1] == '4':
                self.assertTrue('output' in res['signature_vars'])
            elif section.names[0][1] == '5':
                self.assertTrue('output' not in res['signature_vars'])