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

Take Rawusage reset date into account when determining start date for sreport calls #237

Merged
merged 2 commits into from
May 31, 2024

Conversation

Comeani
Copy link
Contributor

@Comeani Comeani commented May 31, 2024

Currently, the start date provided to sreport is just the earliest start date across a group's active allocations. This is not necessarily accurate as the usage value being compared against the limits is the usage since the last raw usage reset.

This PR take the rawusage reset date into consideration, by returning the max of the earliest start date found and the most recent raw usage reset date. We want the max because start dates found prior to the raw usage reset date are what's creating the possibility of > 100% usage in the crc-usage output.

I tested this works properly on the cluster, and that it does not break crc-sus.

Before:

+-----------------------------------------------------------------------------+
|              Resource Allocation Request Information for 'slee'             |
+---------+--------------------------------------------+----------------------+
|    ID   |                   TITLE                    |   EXPIRATION DATE    |
+---------+--------------------------------------------+----------------------+
|  33300  |             NSF MRI Investment             |      2028-04-01      |
+---------+--------------------------------------------+----------------------+
|         |                  CLUSTER                   |    SERVICE UNITS     |
|         |                    ----                    |         ----         |
|         |                    MPI                     |        424315        |
|         |                    GPU                     |         9958         |
|         |                                            |                      |
+---------+--------------------------------------------+----------------------+
|  35516  |    Resource Allocation Request for slee    |      2025-04-08      |
+---------+--------------------------------------------+----------------------+
|         |                  CLUSTER                   |    SERVICE UNITS     |
|         |                    ----                    |         ----         |
|         |                    MPI                     |        50000         |
|         |                    SMP                     |        50000         |
|         |                    GPU                     |        50000         |
|         |                    HTC                     |        150000        |
|         |                                            |                      |
+---------+--------------------------------------------+----------------------+
+-----------------------------------------------------------------------------+
|                     Summary of Usage Across All Clusters                    |
+-------+-------------------------+----------------------+--------------------+
|  MPI  |    TOTAL USED: 74172    |   AWARDED: 474315    |     % USED: 15     |
+-------+-------------------------+----------------------+--------------------+
|       |           USER          |         USED         |       % USED       |
|       |           ----          |         ----         |        ----        |
|       |          shf80          |        74172         |         15         |
|       |          erc117         |          0           |         <1         |
|       |                         |                      |                    |
+-------+-------------------------+----------------------+--------------------+
|  GPU  |      TOTAL USED: 0      |    AWARDED: 59958    |     % USED: 0      |
+-------+-------------------------+----------------------+--------------------+
|       |                         |                      |                    |
+-------+-------------------------+----------------------+--------------------+
|  SMP  |    TOTAL USED: 957293   |    AWARDED: 50000    |    % USED: 1914    | <----- !!!!
+-------+-------------------------+----------------------+--------------------+
|       |           USER          |         USED         |       % USED       |
|       |           ----          |         ----         |        ----        |
|       |          jih145         |        488305        |        976         |
|       |          shf80          |        468982        |        937         |
|       |          erc117         |          6           |         <1         |
|       |                         |                      |                    |
+-------+-------------------------+----------------------+--------------------+
|  HTC  |     TOTAL USED: 2590    |   AWARDED: 150000    |     % USED: 1      |
+-------+-------------------------+----------------------+--------------------+
|       |           USER          |         USED         |       % USED       |
|       |           ----          |         ----         |        ----        |
|       |          jih145         |         2588         |         1          |
|       |          erc117         |          1           |         <1         |
|       |                         |                      |                    |
+-------+-------------------------+----------------------+--------------------+

After:

+-----------------------------------------------------------------------------+
|              Resource Allocation Request Information for 'slee'             |
+---------+--------------------------------------------+----------------------+
|    ID   |                   TITLE                    |   EXPIRATION DATE    |
+---------+--------------------------------------------+----------------------+
|  33300  |             NSF MRI Investment             |      2028-04-01      |
+---------+--------------------------------------------+----------------------+
|         |                  CLUSTER                   |    SERVICE UNITS     |
|         |                    ----                    |         ----         |
|         |                    MPI                     |        424315        |
|         |                    GPU                     |         9958         |
|         |                                            |                      |
+---------+--------------------------------------------+----------------------+
|  35516  |    Resource Allocation Request for slee    |      2025-04-08      |
+---------+--------------------------------------------+----------------------+
|         |                  CLUSTER                   |    SERVICE UNITS     |
|         |                    ----                    |         ----         |
|         |                    MPI                     |        50000         |
|         |                    SMP                     |        50000         |
|         |                    GPU                     |        50000         |
|         |                    HTC                     |        150000        |
|         |                                            |                      |
+---------+--------------------------------------------+----------------------+
+-----------------------------------------------------------------------------+
|                     Summary of Usage Across All Clusters                    |
+-------+-------------------------+-----------------------+-------------------+
|  MPI  |      TOTAL USED: 0      |    AWARDED: 474315    |     % USED: 0     |
+-------+-------------------------+-----------------------+-------------------+
|       |                         |                       |                   |
+-------+-------------------------+-----------------------+-------------------+
|  GPU  |      TOTAL USED: 0      |     AWARDED: 59958    |     % USED: 0     |
+-------+-------------------------+-----------------------+-------------------+
|       |                         |                       |                   |
+-------+-------------------------+-----------------------+-------------------+
|  SMP  |    TOTAL USED: 49952    |     AWARDED: 50000    |     % USED: 99    |
+-------+-------------------------+-----------------------+-------------------+
|       |           USER          |          USED         |       % USED      |
|       |           ----          |          ----         |        ----       |
|       |          shf80          |         42077         |         84        |
|       |          jih145         |          7875         |         15        |
|       |                         |                       |                   |
+-------+-------------------------+-----------------------+-------------------+
|  HTC  |     TOTAL USED: 2588    |    AWARDED: 150000    |     % USED: 1     |
+-------+-------------------------+-----------------------+-------------------+
|       |           USER          |          USED         |       % USED      |
|       |           ----          |          ----         |        ----       |
|       |          jih145         |          2588         |         1         |
|       |                         |                       |                   |
+-------+-------------------------+-----------------------+-------------------+

@Comeani Comeani merged commit 51c8ab4 into main May 31, 2024
11 checks passed
@Comeani Comeani deleted the rawusage_date branch May 31, 2024 16:33
@@ -53,15 +54,16 @@ def get_researchgroup_id(keystone_url: str, account_name: str, auth_header: dict


def get_earliest_startdate(alloc_requests: [dict]) -> date:
"""Given a number of requests, determine the earliest start date across them"""
"""Given a number of requests, determine the earliest start date across them. This takes the most recent rawusage
Copy link
Member

Choose a reason for hiding this comment

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

Minor styling note.

Our team tends to use the Google style guide, which is an extension of PEP8. The first line of docstring should fit on a single line. If you need to add extra details, add a white space followed by a longer multi-line clarification.

see here: https://android.googlesource.com/platform/external/google-styleguide/+/refs/tags/android-s-beta-2/pyguide.md#3_8-comments-and-docstrings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the heads up, my bad for not just getting a quick review on this one. Is there an easy way to get pycharm to point this kind of thing out to me?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think a review was necessary for something this small. I just happened to see it.

As for PyCharm, I have no idea. Maybe there's a plugin? I haven't checked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants