Skip to content

Commit

Permalink
Change return object of the API to integer instead of UserQuotaRespon…
Browse files Browse the repository at this point in the history
…se object
  • Loading branch information
trn024 committed Aug 29, 2024
1 parent 61b2aaa commit 071a762
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/dsmlp/ext/awsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ def list_user_teams(self, username: str) -> ListTeamsResponse:

return ListTeamsResponse(teams=teams)

# Fetch user's GPU quota with AWSED Api and assign to UserQuotaResponse object
def get_user_gpu_quota(self, username: str) -> UserQuotaResponse:
# Fetch user's GPU quota with AWSED Api
def get_user_gpu_quota(self, username: str) -> int:
try:
usrGpuQuota = self.client.get_user_quota(username)
if not usrGpuQuota:
return None
gpu_quota = usrGpuQuota['resources'].get("nvidia.com/gpu", 0) # Access the correct attribute
quota = Quota(user=username, resources={"nvidia.com/gpu": gpu_quota})
return UserQuotaResponse(quota=quota)
UserQuotaResponse(quota=quota)
return gpu_quota
except Exception as e:
self.logger.error(f"Failed to fetch GPU quota for user {username}: {e}")
return None

0 comments on commit 071a762

Please sign in to comment.