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

flux-mini: --setattr: place keys in attributes.system by default with and default values to 1 #4483

Merged
merged 5 commits into from Aug 10, 2022

Conversation

grondo
Copy link
Contributor

@grondo grondo commented Aug 10, 2022

This PR attempts to simplify the flux-mini --setattr interface by placing keys in attributes.system by default (unless the key starts with system., user. or .), since almost all use cases for --setattr are targeting attributes.system. anyway.

Also, similar to --setopt, if a value is not provided, have it default to 1. This allows, for example, attributes.system.prolog.clear-ssd = 1 to be set simply with flux mini batch --setattr=prolog.clear-ssd instead of the more cumbersome flux mini batch --setattr=system.prolog.clear-ssd=1.

Copy link
Member

@garlick garlick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice usability enahncement! LGTM.

Copy link
Member

@chu11 chu11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just one nit

Comment on lines 370 to 371
If KEY does not begin with ``system.``, ``user.``, or ``.``, then
KEY is set in ``attributes.system.`` by default. VAL is optional and
Copy link
Member

@chu11 chu11 Aug 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps is confusing to say "does not begin with system. ... then later say defaults to attributes.system. Perhaps just say system. is assumed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean something like

Suggested change
If KEY does not begin with ``system.``, ``user.``, or ``.``, then
KEY is set in ``attributes.system.`` by default. VAL is optional and
If KEY does not begin with ``system.``, ``user.``, or ``.``, then
`system.` is assumed. VAL is optional and

Yes, that sounds better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I made that change and forced a push. Thanks!

Problem: The flux mini --setattr and --setopt options are handled
differently, which seems unnecessary and could be confusing to users.

Add a new function parse_jobspec_keyval() which combines common code
for handling these options which take jobspec key=value arguments.

As a side effect, --setattr now defaults the value of keys to 1 if
no value is specified, and --setopt can now read values from a file
if the key is prefixed with "^".

Update one test that expects --setattr=key with no value to fail.
Problem: The flux-mini --setattr option is almost always used to set
attributes in the system dictionary, and therefore its use can be
very repetitive and inefficient.

Prepend "system." to the KEY specified in --setattar=KEY=VAL when
it doesn't already begin with "system." or "user.". To force
a different top-level target value, also allow keys to be prefixed
with "." (e.g. --setattr=.foo will set attributes.foo=1).

Fix one use of --setattr=foo=val in the testsuite with
--setattr=.foo=val.

Fixes flux-framework#4481
Problem: The description of --setattr in `flux mini --help` output
is out of date.

Update the description of the --setattr to match recent changes.
Problem: The description of the flux-mini --setattr option is out
of date in the man page.

Update the description of --setattr in flux-mini(1).
Problem: The flux-mini --setattr tests do not verify that --setattr=KEY
sets the attribute KEY in the system dictionary by default, and that
--setattr now defaults the value to 1 when value is not specified.

Test these conditions in the existing --setattr tests in
t2700-mini-cmd.t.

Also, update the test use jq directly to compare values instead of
reading the values with jq and comparing with test.
@codecov
Copy link

codecov bot commented Aug 10, 2022

Codecov Report

Merging #4483 (ac5f290) into master (8134e0c) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head ac5f290 differs from pull request most recent head 573dce5. Consider uploading reports for the commit 573dce5 to get more accurate results

@@            Coverage Diff             @@
##           master    #4483      +/-   ##
==========================================
- Coverage   83.37%   83.36%   -0.01%     
==========================================
  Files         401      401              
  Lines       67517    67515       -2     
==========================================
- Hits        56291    56284       -7     
- Misses      11226    11231       +5     
Impacted Files Coverage Δ
src/cmd/flux-mini.py 91.92% <100.00%> (-0.03%) ⬇️
src/cmd/builtin/proxy.c 81.04% <0.00%> (-0.95%) ⬇️
src/modules/cron/cron.c 82.47% <0.00%> (-0.45%) ⬇️
src/common/libflux/handle.c 83.49% <0.00%> (-0.39%) ⬇️
src/cmd/flux-job.c 87.29% <0.00%> (-0.14%) ⬇️
src/modules/job-exec/job-exec.c 76.57% <0.00%> (+0.16%) ⬆️
src/common/libsubprocess/subprocess.c 88.19% <0.00%> (+0.29%) ⬆️

@grondo
Copy link
Contributor Author

grondo commented Aug 10, 2022

Thanks! Setting MWP.

@mergify mergify bot merged commit 98d2331 into flux-framework:master Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants