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

src: remove flux_account_shares.cpp in favor of just using -t option with view-bank #471

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

cmoussa1
Copy link
Member

Problem

flux-accounting has two identical ways to print out the hierarchy of its accounting database: the flux account-shares command (a
.cpp file) and an optional argument passed into the view-bank command. It would be less confusing to have two different options that do the same thing, especially since the .cpp file requires a dash - in between "account" and "shares", which doesn't match the rest of the flux-accounting commands.


This PR removes flux_account_shares.cpp from flux-accounting and converts the various calls in its testsuite to just use the -t option of the view-bank command. It also converts the expected files used for these tests to match the higher precision output from the view-bank command, particularly the job-usage values. I've added a -P/--parsable option to view-bank to print out hierarchies in a pipe-delimited (|) format.

I've also broken up t1000-print-hierarchy.t into multiple, smaller tests.

@cmoussa1 cmoussa1 added the improvement Upgrades to an already existing feature label Jul 29, 2024
@cmoussa1 cmoussa1 requested a review from jameshcorbett July 29, 2024 17:25
Copy link
Member

@jameshcorbett jameshcorbett left a comment

Choose a reason for hiding this comment

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

Looks good, two small comments.

Also, depending on what your use-case is, have you considered an option to output the hierarchy info as JSON or to allow users to specify what information they want printed out and in what format? Like flux jobs does:

flux jobs ƒ2WFJyd8B -o"{id}|{username}"
JOBID|USER
ƒ2WFJyd8B|corbett8

@@ -1,7 +1,6 @@
# This list is included in both TESTS and dist_check_SCRIPTS.
TESTSCRIPTS = \
t0000-sharness.t \
t1000-print-hierarchy.t \
Copy link
Member

Choose a reason for hiding this comment

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

It looks like this file isn't deleted, even though it's removed from the testsuite?

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yeah, I forgot to delete this file. Thanks for catching that

+ str(user[2])
+ "|"
+ str(user[3])
+ "\n"
Copy link
Member

Choose a reason for hiding this comment

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

did you consider f"{indent} {bank}|{user[0]}|{user[1]}|{user[2]}|{user[3]}\n"?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't even consider f-strings 🤦 thank you for pointing that out! I'm gonna switch to using these instead; much cleaner

cmoussa1 added 4 commits July 30, 2024 08:40
Problem: The "view-bank" command does not have an option to print out
the database hierarchy in a parsable format.

Add an option to print out a pipe-delimited ('|') hierarchy of the
flux-accounting database, starting with the bank passed in.
Problem: flux-accounting has two identical ways to print out the
hierarchy of its accounting database: the flux account-shares command (a
.cpp file) and an optional argument passed into the "view-bank" command.
It would be less confusing to have two different options that do the
same thing, especially since the .cpp file requires a dash '-' in
between "account" and "shares", which doesn't match the rest of the
flux-accounting commands.

Convert the sharness tests in t1000-print-hierarchy.t into multiple,
smaller sets of tests. Use the "-t" option from the "view-bank" command
instead of calling "flux account-shares".

Since the "-t" optional argument in the "view-bank" command prints job
usage values with more precision, edit the expected files to match this
precision.
Problem: There are a couple of instances throughout the testsuite that
call "flux account-shares", but there is a cleaner option to just use
the "-t" optional argument from the "view-bank" command.

Convert the calls from "flux account-shares" to just use "view-bank -t".
Edit the expected files in the testsuite to account for the precision
that "view-bank -t" includes in its output of the database hierarchy.
Problem: flux_account_shares.cpp is no longer needed by flux-accounting
since its function is replicated by the "-t" option in the "view-bank"
command.

Remove flux_account_shares.cpp from flux-accounting as well as any
references to it throughout documentation.
@cmoussa1 cmoussa1 force-pushed the rm.flux-account-shares branch from d6e72e9 to 3cf6282 Compare July 30, 2024 15:42
@cmoussa1
Copy link
Member Author

Thanks for reviewing @jameshcorbett! I've force-pushed up some fixes/changes based on your suggestions.

Also, depending on what your use-case is, have you considered an option to output the hierarchy info as JSON or to allow users to specify what information they want printed out and in what format?

This is a good suggestion. view-user currently has support to output its info in JSON format but it is not available for bank information yet. I'll look into adding some support for this in the near future.

Setting MWP here shortly

@mergify mergify bot merged commit 5b9706c into flux-framework:master Jul 30, 2024
11 checks passed
cmoussa1 added a commit to cmoussa1/flux-accounting that referenced this pull request Aug 7, 2024
Problem: flux_account_shares.cpp was removed in flux-framework#471, but there is
still a target definition for it in the top-level Makefile.am that
is left over.

Remove the left over targets.
cmoussa1 added a commit to cmoussa1/flux-accounting that referenced this pull request Aug 7, 2024
Problem: flux_account_shares.cpp was removed in flux-framework#471, but there is
still a compile definition for it in the top-level Makefile.am that
is left over.

Remove the left over compilation instructions.
@cmoussa1 cmoussa1 deleted the rm.flux-account-shares branch February 13, 2025 18:21
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