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

python: create new BankFormatter subclass, restructure view-bank to use new class #525

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

cmoussa1
Copy link
Member

@cmoussa1 cmoussa1 commented Nov 4, 2024

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 the view-bank command, particularly with the --tree, --users, and -P options. A new --fields option is also added to match the customization available in the list-banks command. It removes the helper functions previously defined in bank_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 new BankFormatter subclass.

@cmoussa1 cmoussa1 added improvement Upgrades to an already existing feature low priority items that can be worked on at a later date labels Nov 4, 2024
@cmoussa1 cmoussa1 force-pushed the restructure.bank.views branch 2 times, most recently from 49aecd2 to fc18eb6 Compare November 19, 2024 18:26
@cmoussa1 cmoussa1 changed the title [WIP] python: create new BankFormatter subclass, restructure view-bank to use new class python: create new BankFormatter subclass, restructure view-bank to use new class Nov 19, 2024
@cmoussa1 cmoussa1 marked this pull request as ready for review November 19, 2024 18:33
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: There is a test in t1023-flux-account-banks.t that looks for a
specific error message when trying to view a bank that does not exist,
but this error message has changed slightly with the introduction of
the BankFormatter subclass.

Change the expected error message in t1023-flux-account-banks.t to
account for the new message format.
Problem: The parsable option for viewing bank heirarchies 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.
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 low priority items that can be worked on at a later date
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant