Skip to content

Commit

Permalink
fix input/output options in basic_submit arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
dsschult committed Oct 17, 2024
1 parent c7da7ff commit 3844711
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
10 changes: 10 additions & 0 deletions iceprod/core/exe.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,16 @@ def scope_env(cfg: ConfigParser, obj: dict, upperenv: Optional[Env] = None, logg
'parameters': {},
'input_files': set(),
'output_files': set(),
'upper_input_files': set(),
'upper_output_files': set(),
'environment': {
'OS_ARCH': '$OS_ARCH',
}
}
if upperenv:
env['parameters'].update(upperenv['parameters'])
env['upper_input_files'] = upperenv['input_files'] | upperenv['upper_input_files']
env['upper_output_files'] = upperenv['output_files'] | upperenv['upper_output_files']

logger = logger if logger else logging.getLogger()

Expand Down Expand Up @@ -185,6 +189,12 @@ def scope_env(cfg: ConfigParser, obj: dict, upperenv: Optional[Env] = None, logg
if ret:
env['output_files'].add(ret)

# add input and output to parseable options
cfg.config['options']['input'] = ' '.join(d.local for d in (env['input_files'] | env['upper_input_files']))
cfg.config['options']['output'] = ' '.join(d.local for d in (env['output_files'] | env['upper_output_files']))
logging.info('input: %r', cfg.config['options']['input'])
logging.info('output: %r', cfg.config['options']['output'])

except util.NoncriticalError:
logger.warning('Noncritical error when setting up environment', exc_info=True)
except Exception:
Expand Down
5 changes: 4 additions & 1 deletion tests/core/exe_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,8 @@ async def test_write_to_script_data_task_files(tmp_path):
'trays': [{
'modules': [{
'env_clear': False,
'src': 'foo.py'
'src': 'foo.py',
'args': '--foo -b $(input) $(output)',
}]
}],
'data': [{
Expand Down Expand Up @@ -572,6 +573,8 @@ async def test_write_to_script_data_task_files(tmp_path):
assert ws.infiles == {Data('https://foo.bar/baz', 'baz', Transfer.TRUE), Data('https://foo.bar/blah', 'blah', Transfer.TRUE)}
assert ws.outfiles == {Data('https://foo.bar/1234', '1234', Transfer.TRUE), Data('https://foo.bar/abcde', 'abcde', Transfer.TRUE)}
script = open(scriptpath).read()
lines = [line for line in script.split('\n') if not (not line.strip() or line.startswith('#') or line.startswith('set '))]
assert lines[-1] == 'python foo.py --foo -b baz blah 1234 abcde'


async def test_write_to_script_data_dups(tmp_path):
Expand Down

0 comments on commit 3844711

Please sign in to comment.