Skip to content

Commit

Permalink
Consider most recent rawusage reset date when determining date range …
Browse files Browse the repository at this point in the history
…to gather usage info over
  • Loading branch information
Comeani committed May 31, 2024
1 parent b69254f commit cbac641
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion 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 = '2024-05-07'


def get_auth_header(keystone_url: str, auth_header: dict) -> dict:
Expand Down Expand Up @@ -53,14 +54,18 @@ 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

if earliest_date < RAWUSAGE_RESET_DATE:
return RAWUSAGE_RESET_DATE

return earliest_date


Expand Down

0 comments on commit cbac641

Please sign in to comment.