Skip to content

Commit

Permalink
Fix the trigger of sos_step(workflow) when the step itself is an auxi…
Browse files Browse the repository at this point in the history
…liary step #983
  • Loading branch information
Bo Peng committed Jun 16, 2018
1 parent d6a4b82 commit 2ca8a98
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/sos/step_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def analyze_section(section: SoS_Step, default_input: Optional[sos_targets] = No
SoS_exec('import os, sys, glob', None)
SoS_exec('from sos.runtime import *', None)

env.logger.trace(
f'Analyzing {section.step_name()} with step_output {step_output}')

#
# Here we need to get "contant" values from the global section
# Because parameters are considered variable, they has to be
Expand Down Expand Up @@ -244,7 +247,7 @@ def analyze_section(section: SoS_Step, default_input: Optional[sos_targets] = No
# finally, tasks..
if section.task:
signature_vars |= accessed_vars(section.task)
if '__default_output__' in env.sos_dict and step_output.determined():
if 'provides' in section.options and '__default_output__' in env.sos_dict and step_output.determined():
for out in env.sos_dict['__default_output__']:
# 981
if not isinstance(out, sos_step) and out not in step_output:
Expand Down Expand Up @@ -1267,6 +1270,9 @@ def run(self):
# _index is needed for pre-input action's active option and for debug output of scripts
env.sos_dict.set('_index', 0)

env.logger.trace(
f'Executing {env.sos_dict["step_name"]} with step_input {env.sos_dict["step_input"]} and step_output {env.sos_dict["step_output"]}')

# look for input statement.
input_statement_idx = [idx for idx, x in enumerate(
self.step.statements) if x[0] == ':' and x[1] == 'input']
Expand Down
3 changes: 3 additions & 0 deletions src/sos/workflow_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,9 @@ def resolve_dangling_targets(self, dag: SoS_DAG, targets: Optional[sos_targets]=
# get the step names
sections = sorted([x[0] for x in mo],
key=lambda x: x.step_name())
# this is only useful for executing auxiliary steps and
# might interfere with the step analysis
env.sos_dict.pop('__default_output__')
# no default input
default_input: sos_targets = sos_targets()
#
Expand Down
30 changes: 30 additions & 0 deletions test/test_execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,36 @@ def testMultiSoSStep(self):
with open('a_1') as a1, open('a_2') as a2:
self.assertEqual(a1.read(), a2.read())

def testDependsAuxiAndForward(self):
'''Test depends on auxiliary, which then depends on a forward-workflow #983'''
file_target('a_1').remove('both')
file_target('a_2').remove('both')
script = SoS_Script('''
[hg_1]
output: 'a_1'
sh:
echo "something" > a_1
[hg_2]
[star: provides = "a_2"]
depends: sos_step('hg')
sh:
cp a_1 a_2
[default]
depends: "a_2"
''')
wf = script.workflow()
res = Base_Executor(wf).run()
self.assertEqual(res['__completed__']['__step_completed__'], 4)
self.assertTrue(os.path.isfile('a_1'))
self.assertTrue(os.path.isfile('a_2'))
with open('a_1') as a1, open('a_2') as a2:
self.assertEqual(a1.read(), a2.read())



if __name__ == '__main__':
unittest.main()

0 comments on commit 2ca8a98

Please sign in to comment.