Skip to content

Commit

Permalink
Merge pull request #5817 from grondo/issue#5816
Browse files Browse the repository at this point in the history
fix `flux submit` and `bulksubmit` handling of mustache templates in command and args
  • Loading branch information
mergify[bot] committed Mar 25, 2024
2 parents fea7f25 + 1358857 commit 0300968
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/bindings/python/flux/cli/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,12 +629,14 @@ def __init__(self, args, inputs=None, **kwargs):
self.command = []
for arg in args.command:
try:
result = arg.format(*inputs, **kwargs).split("::list::")
val = self.preserve_mustache(arg)
result = val.format(*inputs, **kwargs).split("::list::")
newval = self.restore_mustache(result)
except (IndexError, KeyError):
LOGGER.error("Invalid replacement string in command: '%s'", arg)
sys.exit(1)
if result:
self.command.extend(result)
if newval:
self.command.extend(newval)

# Format all supported mutable options defined in `mutable_args`
# Note: only list and string options are supported.
Expand Down
9 changes: 9 additions & 0 deletions t/t2713-python-cli-bulksubmit.t
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,15 @@ test_expect_success 'flux bulksubmit: preserves mustache templates' '
EOF
test_cmp mustache.expected mustache.out
'
test_expect_success 'flux bulksubmit: preserves mustache templates in command' '
flux bulksubmit --dry-run echo {{tmpdir}} ::: 0 1 >mustache-cmd.out &&
test_debug "cat mustache-cmd.out" &&
cat <<-EOF > mustache-cmd.expected &&
bulksubmit: submit echo {{tmpdir}}
bulksubmit: submit echo {{tmpdir}}
EOF
test_cmp mustache-cmd.expected mustache-cmd.out
'
test_expect_success 'flux submit --log works and can substitute {cc}' '
flux submit --log=job{cc}.id --cc=1-5 hostname &&
for id in $(seq 1 5); do
Expand Down

0 comments on commit 0300968

Please sign in to comment.