Skip to content

Commit

Permalink
Allow the use of named_output and output_from in dependent statement #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Bo Peng committed Jan 25, 2019
1 parent f481be7 commit d6edc18
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/sos/section_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ def get_signature_vars(section):
return {x for x in signature_vars if not x.startswith('__')}

def get_step_depends(section):

step_depends: sos_targets = sos_targets([])

input_idx = find_statement(section, 'input')
if input_idx is not None:
depends_idx = find_statement(section, 'depends')
for stmt_idx in ([] if input_idx is None else [input_idx]) + ([] if depends_idx is None else [depends_idx]):
# input statement
stmt = section.statements[input_idx][2]
stmt = section.statements[stmt_idx][2]
if 'output_from' in stmt:
step_depends.extend([sos_step(x) for x in get_output_from_steps(stmt, section.last_step)])
if 'named_output' in stmt:
Expand All @@ -165,16 +167,15 @@ def get_step_depends(section):
else:
raise ValueError(f'Unacceptable keyword argument {par[0]} for named_output()')


depends_idx = find_statement(section, 'depends')
if depends_idx is not None:
value = section.statements[depends_idx][2]
try:
svars = ['output_from', 'named_output']
old_values = {x:env.sos_dict._dict[x] for x in svars if x in env.sos_dict._dict}
# output_from and named_output has been processed
env.sos_dict._dict.update({
'output_from': no_output_from,
'named_output': no_named_output
'output_from': lambda *args, **kwargs: None,
'named_output': lambda *args, **kwargs: None,
})
args, kwargs = SoS_eval(f'__null_func__({value})',
extra_dict=env.sos_dict._dict)
Expand Down

0 comments on commit d6edc18

Please sign in to comment.