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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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.

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