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

support expandable width output formats and use them in flux resource list to avoid truncation of queue field #6284

Merged
merged 5 commits into from
Sep 15, 2024

Conversation

grondo
Copy link
Contributor

@grondo grondo commented Sep 14, 2024

This PR adds two new output format "sentinels" +: and ?+: to the OutputFormat class that allow automated adjustment of the field width to avoid truncation. +: only does the expansion, while ?+: combines the functionality of +: and ?: and expands the field to the maximum observed width and removes the field if all entries would result in an "empty" value.

Then ?+: is applied to flux resource list default output for queue and ngpus fields. This avoids truncation of the QUEUE column, which may contain comma separated list of queues on system instances (and in the case of ngpus saves a couple characters of width in the common case)

src/cmd/flux-pgrep.py Dismissed Show resolved Hide resolved
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! Looks good to me. I noticed one comment typo.

Comment on lines 842 to 843
# Save a format without any spec to allow deterimination of
# maximum width after formatting all items:
Copy link
Member

Choose a reason for hiding this comment

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

s/deterimination/determination/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Fixed that and I also dropped the flux-pgrep codeql commit since it didn't help workaround the codeql false positive. Will set MWP now.

Problem: When generating formatted output, there are times where
truncating a wide field is not desirable, for example when a comma
separated list is being displayed, truncation can completely hide
some entries. However, the only current alternative is to use a
very wide field in the output format by default, which is also not
desirable since it wastes horizontal space to handle an uncommon case.

Extend the current sentinel `?:`, which specifies that a field is
to be collapsed if the output width for all entries is 0, with a
new sentinel `+:`, which indicates the field width should be increased
to handle the largest width of all displayed items. To take both
actions `?+:` is also supported.

Extend `OutputFormat.filter_empty()` to handle these new sentinels
and modify the format spec if necessary before returning the new
format to the caller.
Problem: The name of the filter_empty() method of the OutputFormat
class is misleading since it now does more than just filter empty
fields.

Rename the method to just filter(). Update callers.
Problem: There are no tests that ensure the width adjustment sentinels
`+:` and `?+:` are functional.

Add some tests in t2800-jobs-cmd.t to ensure these sentinels work as
expected.
Problem: The expandable format sentinels `+:` and `?+:` are not
documented anywhere.

Add a description to the `OUTPUT FORMAT` section in flux-jobs(1).
Problem: The fixed width of the queue field in `flux resource list`
causes confusion for users with overlapping queues because the queues
are joined into a comma separated list and truncation could cause
some queues to be completely left out of the field.

Now that the OutputFormat class supports "expandable" fields, use this
with the `queue` field in `flux resource list` so that no truncation
is guaranteed without using a large width by default.

Also apply the expandable field to ngpus to save some horizontal
space in the common case.
@mergify mergify bot merged commit ef0d279 into flux-framework:master Sep 15, 2024
33 checks passed
Copy link

codecov bot commented Sep 15, 2024

Codecov Report

Attention: Patch coverage is 96.96970% with 2 lines in your changes missing coverage. Please review.

Project coverage is 83.36%. Comparing base (e055bec) to head (a0cea0f).
Report is 6 commits behind head on master.

Files with missing lines Patch % Lines
src/bindings/python/flux/util.py 96.87% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #6284   +/-   ##
=======================================
  Coverage   83.36%   83.36%           
=======================================
  Files         522      522           
  Lines       85985    86036   +51     
=======================================
+ Hits        71682    71726   +44     
- Misses      14303    14310    +7     
Files with missing lines Coverage Δ
src/cmd/flux-jobs.py 96.49% <100.00%> (ø)
src/cmd/flux-pgrep.py 95.12% <100.00%> (ø)
src/cmd/flux-resource.py 94.93% <ø> (ø)
src/bindings/python/flux/util.py 95.79% <96.87%> (+0.02%) ⬆️

... and 8 files with indirect coverage changes

@grondo grondo deleted the expanding-formats branch September 15, 2024 18:05
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.

2 participants