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

formatter: add new JobsFormatter class, restructure view-job-records to use new class #563

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

Conversation

cmoussa1
Copy link
Member

Problem

The formatter module in flux-accounting does not have a class for formatting the output of job records which would be useful because the flux-accounting Python bindings manually define the formatting of these job records within its bindings.


This PR creates a new class called JobsFormatter which takes a list of job records for formatting. It adds a method called as_columns(), which will create column-separated output of job records to be returned while supporting custom formatting (i.e allowing custom formatting of these columns).

view-job-records is restructured to use the new JobsFormatter class instead of defining its own print function as well as modified to include a --fields optional argument to the command to allow the user to specify which fields to include in their output if they so choose.

Finally, a couple of the view-job-records tests are cleaned up to account for the use of the new formatter class.

Problem: The formatter module in flux-accounting does not have a class
for formatting the output of job records which would be useful because
the flux-accounting Python bindings manually define the formatting of
these job records within its bindings.

Create a new class called JobsFormatter which takes a list of
job records for formatting. Add a method called as_columns() which will
create column-separated output of job records to be returned while
supporting custom formatting (i.e allowing custom formatting of these
columns).
Problem: The convert_to_str() function defines its own formatting for
job records to be returned with the view-job-records command, but the
formatter module in flux-accounting now has its own JobsFormatter class
that does this (and also includes custom formatting).

Edit the convert_to_str() function to create a JobsFormatter object,
initialized with the list of job_records to be returned. Add a --fields
optional argument to the view-job-records command to allow the user to
specify which fields to include in their output if they so choose.
Problem: The output of the view-job-records command has been slightly
adjusted as a result of including custom formatting in its output, but
there are a couple of tests throughout the testsuite that are now
out-of-date because they look for the old format.

Adjust the tests that look for view-job-records output throughout the
testsuite to account for the new formatting. Get rid of a expected file
in the testsuite in favor of just creating that file within the test
itself.
@cmoussa1 cmoussa1 added improvement Upgrades to an already existing feature commands related to the flux-accounting commands/bindings labels Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commands related to the flux-accounting commands/bindings improvement Upgrades to an already existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant