Skip to content

Commit

Permalink
Take Rawusage reset date into account when determining start date for…
Browse files Browse the repository at this point in the history
… `sreport` calls (#237)

* Consider most recent rawusage reset date when determining date range to gather usage info over

* use date instead of string and perform a max
  • Loading branch information
Comeani authored May 31, 2024
1 parent b69254f commit 51c8ab4
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions apps/utils/keystone.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

KEYSTONE_URL = "https://keystone.crc.pitt.edu"
CLUSTERS = {1: 'MPI', 2: 'SMP', 3: 'HTC', 4: 'GPU'}
RAWUSAGE_RESET_DATE = date.fromisoformat('2024-05-07')


def get_auth_header(keystone_url: str, auth_header: dict) -> dict:
Expand Down Expand Up @@ -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
reset into account for accuracy against current limits and to prevent seeing >100% usage."""

earliest_date = date.today()
for request in alloc_requests:
start = date.fromisoformat(request['active'])
if start < earliest_date:
earliest_date = start

return earliest_date
return max(earliest_date, RAWUSAGE_RESET_DATE)


def get_most_recent_expired_request(keystone_url: str, group_pk: int, auth_header: dict) -> [dict]:
Expand Down

0 comments on commit 51c8ab4

Please sign in to comment.