Skip to content

Commit

Permalink
Merge pull request #6680 from wihobbs/issue-6678
Browse files Browse the repository at this point in the history
improve error message on invalid formatting of shell options
  • Loading branch information
mergify[bot] authored Mar 4, 2025
2 parents 621c7b8 + 5acc90d commit 50dcd44
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/bindings/python/flux/cli/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,10 @@ def update_keyval(self, keyval):
value = json.loads(value)
except json.decoder.JSONDecodeError:
value = str(value)
set_treedict(self.config, key, value)
try:
set_treedict(self.config, key, value)
except TypeError as e:
raise TypeError(f"failed to set {key} to {value}: {e}")
return self

def update_file(self, path, extension=".toml"):
Expand Down
5 changes: 4 additions & 1 deletion src/bindings/python/flux/job/Jobspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,10 @@ def setattr(self, key, val):
if not key.startswith(("user.", "system.")):
key = "system." + key
key = "attributes." + key
set_treedict(self.jobspec, key, val)
try:
set_treedict(self.jobspec, key, val)
except TypeError as e:
raise TypeError(f"failed to set {key} to {val}: {e}")

def setattr_shell_option(self, key, val):
"""
Expand Down
6 changes: 6 additions & 0 deletions t/t2712-python-cli-alloc.t
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ test_expect_success 'flux alloc: mpi option can be overridden' '
flux alloc -o mpi=foo -N1 --dry-run hostname | \
jq -e ".attributes.system.shell.options.mpi = \"foo\""
'
test_expect_success 'flux alloc: -o foo.bar cannot override -o foo' '
test_must_fail flux alloc -o foo -N1 -o foo.bar=hi --dry-run hostname >shellopt.out 2>&1 &&
test_debug "cat shellopt.out" &&
grep "failed to set attributes.system.shell.options.foo.bar to hi" shellopt.out
'

test_expect_success 'flux alloc: MPI vars are not set in initial program' '
flux queue start &&
unset OMPI_MCA_pmix &&
Expand Down

0 comments on commit 50dcd44

Please sign in to comment.