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

view-user --parsable: improve output formatting #514

Merged
merged 1 commit into from
Oct 17, 2024

Conversation

cmoussa1
Copy link
Member

@cmoussa1 cmoussa1 commented Oct 16, 2024

Problem

Since the formatting of the columns in the output of view-user --parsable is dependent on the length of the longest column name, the width of every column is forced to match, which can result in some ugly screen wrapping even in a relatively small font.

$ flux account view-user moussa1 --parsable
creation_time   mod_time        active          username        userid          bank            default_bank    shares          job_usage       fairshare       max_running_jobsmax_active_jobs max_nodes       queues          projects        default_project 
1661527404      1661527404      1               moussa1         58985           lc              lc              1               0.0             0.457547        100             1000            2147483647                      *               *   

This PR improves the formatting of view-user --parsable by making the width of each column dynamic based on the length of each column name instead of based on the length of the longest column name. Below is an example:

$ flux account view-user user1 --parsable
creation_time | mod_time   | active | username | userid | bank | default_bank | shares | job_usage | fairshare | max_running_jobs | max_active_jobs | max_nodes  | queues | projects | default_project
--------------+------------+--------+----------+--------+------+--------------+--------+-----------+-----------+------------------+-----------------+------------+--------+----------+----------------
1729113599    | 1729113599 | 1      | user1    | 65534  | A    | A            | 1      | 0.0       | 0.5       | 5                | 7               | 2147483647 |        | *        | *   

@cmoussa1 cmoussa1 added the improvement Upgrades to an already existing feature label Oct 16, 2024
@cmoussa1 cmoussa1 requested a review from wihobbs October 16, 2024 21:37
@wihobbs
Copy link
Member

wihobbs commented Oct 17, 2024

Some longer term things you could consider doing:

  • take a format string, similar to the flux jobs -o option, so that you only print what the user wants
  • bounding the width of the table to the width of a user's terminal (I almost asked you to do this here but I think it's tricky with the amount of data in the table)

@cmoussa1
Copy link
Member Author

Thanks @wihobbs! That's a good suggestion. I'll open an "idea" issue thread that might look into supporting just taking a format string (for all of the data from the DB, not just users). Setting MWP here!

Problem: Since the formatting of the columns in the output of view-user
--parsable is dependent on the length of the longest column name, the
width of every column is forced to match, which can result in some ugly
screen wrapping even in a relatively small font.

Improve the view-user --parsable formatting option by making the width
of each column dynamic based on the length of each column name instead
of based on the length of the longest column name.
@cmoussa1 cmoussa1 force-pushed the improve.view-user.parsable branch from 9d551ec to f53e209 Compare October 17, 2024 18:19
@mergify mergify bot merged commit a6f7aa9 into flux-framework:master Oct 17, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Upgrades to an already existing feature merge-when-passing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants