Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve error message on invalid formatting of shell options #6680

Merged
merged 2 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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}")

Check warning on line 428 in src/bindings/python/flux/cli/base.py

View check run for this annotation

Codecov / codecov/patch

src/bindings/python/flux/cli/base.py#L427-L428

Added lines #L427 - L428 were not covered by tests
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
Loading