-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added handling for lifetime quota changes
- Loading branch information
1 parent
65c8c87
commit 22bb13e
Showing
2 changed files
with
18 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -232,9 +232,14 @@ def print_user_quota(self) -> None: | |
Print the user's quota information | ||
""" | ||
user_quota = self.cas_api_service.get_user_quota() | ||
lifetime_quota = user_quota["lifetime_quota"] or "unlimited" | ||
remaining_lifetime_quota = ( | ||
user_quota["remaining_lifetime_quota"] or "unlimited" | ||
) | ||
self.__print( | ||
f"User quota: {user_quota['quota']}, Remaining quota: {user_quota['remaining_quota']}, " | ||
f"Reset date: {user_quota['quota_reset_date']}" | ||
f"Weekly quota: {user_quota['weekly_quota']}, Remaining weekly quota: {user_quota['remaining_weekly_quota']}, " | ||
f"Weekly quota reset date: {user_quota['quota_reset_date']}\n" | ||
f"Lifetime quota: {lifetime_quota}, Remaining lifetime quota: {remaining_lifetime_quota} " | ||
) | ||
|
||
def __get_async_sharded_request_callback( | ||
|
@@ -445,9 +450,14 @@ def __validate_cells_under_quota(self, cell_count: int) -> None: | |
:param cell_count: Number of cells in the input data | ||
""" | ||
user_quota = self.cas_api_service.get_user_quota() | ||
if cell_count > user_quota["remaining_quota"]: | ||
if cell_count > (user_quota["remaining_lifetime_quota"] or cell_count): | ||
raise exceptions.QuotaExceededError( | ||
f"Number of cells in the input data ({cell_count}) exceeds the user's remaining lifetime quota ({user_quota['remaining_lifetime_quota']}). " | ||
f"If you would like to discuss removing your lifetime quota, please reach out to [email protected]" | ||
) | ||
elif cell_count > user_quota["remaining_weekly_quota"]: | ||
raise exceptions.QuotaExceededError( | ||
f"Number of cells in the input data ({cell_count}) exceeds the user's remaining quota ({user_quota['remaining_quota']}). " | ||
f"Number of cells in the input data ({cell_count}) exceeds the user's remaining quota ({user_quota['remaining_weekly_quota']}). " | ||
f"The user's quota will be reset to {user_quota['quota']} on {user_quota['quota_reset_date']}." | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters