-
Notifications
You must be signed in to change notification settings - Fork 10
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
python: create new BankFormatter
subclass, restructure view-bank
to use new class
#525
python: create new BankFormatter
subclass, restructure view-bank
to use new class
#525
Conversation
49aecd2
to
fc18eb6
Compare
BankFormatter
subclass, restructure view-bank
to use new classBankFormatter
subclass, restructure view-bank
to use new class
fc18eb6
to
3ae8630
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
if users: | ||
for user in users: | ||
hierarchy += ( | ||
f"{indent} {bank}|{user[0]}|{user[1]}|{user[2]}|{user[3]}\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beware the magic numbers here (and in the lines below...)
@@ -54,7 +54,7 @@ test_expect_success 'view database hierarchy' ' | |||
' | |||
|
|||
test_expect_success 'view database hierarchy in a parsable format' ' | |||
flux account view-bank -P root > small_no_tie_parsable.test && | |||
flux account view-bank --tree -P root > small_no_tie_parsable.test && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commit nit: hierarchies
3ae8630
to
bbcfb18
Compare
Problem: The AccountingFormatter class has good overarching methods for printing the results of a query to the flux-accounting database, but there is some functionality specific to viewing bank information from the database that could use its own subclass. Add a new subclass called BankFormatter, which contains unique methods for viewing bank/user information in hierarchical and parsable formats with the view-bank command. Remove the helper functions previously defined in bank_subcommands.py in favor of using this new subclass. Add a --fields optional argument to allow the user to customize which columns they want to be returned when looking at a row of information for a bank.
Problem: view-bank does not have many unit tests, especially for calling view-bank with custom outputs or viewing information in either JSON or table format. Add some unit tests.
Problem: The --users option for the view-bank command lists a lot of columns for every user row in the association_table, which crowds the output with potentially unneccessary information when looking at which users belong to the bank being looked at. The format of this option has been changed to: 1) be formatted in tables, and 2) only include a couple of columns per user row Adjust the expected output of the --users optional argument to account for the use of the BankFormatter subclass.
Problem: The --tree option for the view-bank command still lists the default information for the bank being viewed *before* printing the bank hierarchy, which is not necessary when the user passes the --tree option. Now that the view_bank() function has been reworked to use the new BankFormatter subclass, these options are more distinct from one another, and the --tree option no longer includes this info for the single bank at the top of the output when the --tree option is passed. Adjust the expected output in the sharness tests to account for the removal of the default info for the passed-in bank when calling view-bank with the --tree option.
Problem: The default output of the view-bank command is now JSON by default, but one of the sharness tests still looks for the old format before the introduction of the BankFormatter subclass. Change the expected output to match the new format of calling view-bank with no optional arguments.
Problem: The parsable option for viewing bank hierarchies in the flux-accounting database is meant just to be another option for the --tree option, but now the -P option requires --tree to also be passed when calling view-bank. There are multiple tests in the flux-accounting testsuite that call -P without --tree, and thus, these tests fail. Add --tree to the view-bank -P calls in the testsuite.
Problem: The view-bank command does not support the combination of both --tree and --fields, but there is no check for this in the testsuite. Add a test in t1023-flux-account-banks.t that makes sure the appropriate error message is raised when combining both --tree and --fields.
Problem: The AccountingFormatter class has good overarching methods for printing the results of a query to the flux-accounting database, but there is some functionality specific to viewing bank information from the database that could use its own subclass. Add a new subclass called BankFormatter, which contains unique methods for viewing bank/user information in hierarchical and parsable formats with the view-bank command. Remove the helper functions previously defined in bank_subcommands.py in favor of using this new subclass. Add a --fields optional argument to allow the user to customize which columns they want to be returned when looking at a row of information for a bank.
bbcfb18
to
bd78e16
Compare
Thanks @wihobbs! I've rebased this branch to catch up to |
Problem
The
AccountingFormatter
class has good overarching methods for printing the results of a query to the flux-accounting database, but there is some functionality specific to viewing bank information from the database that could use its own subclass.This PR adds a new subclass called
BankFormatter
, which contains unique methods for viewing bank/user information in hierarchical and parsable formats with theview-bank
command, particularly with the--tree
,--users
, and-P
options. A new--fields
option is also added to match the customization available in thelist-banks
command. It removes the helper functions previously defined inbank_subcommands.py
in favor of using this new subclass.I've added some new unit tests for the output of the reworked
view-bank
command to the testsuite as well as adjusted a number of expected output files throughout the testsuite to account for the use of the newBankFormatter
subclass.