Skip to content

Commit

Permalink
Update methods that failed to rename during refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
djperrefort committed Aug 30, 2024
1 parent e9859a7 commit 898f403
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion keystone_api/apps/allocations/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ def historical_usage(self, account: ResearchGroup, cluster: 'Cluster') -> int:

return self.approved_allocations(account, cluster).filter(
request__expire__lte=date.today()
).order_by("request__expire").aggregate(Sum("final"))['final__sum'] or 0
).aggregate(Sum("final"))['final__sum'] or 0
5 changes: 2 additions & 3 deletions keystone_api/apps/allocations/tasks/limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def update_limit_for_account(account: ResearchGroup, cluster: Cluster) -> None:
"""

# Calculate service units for expired and active allocations
closing_sus = Allocation.objects.expired_service_units(account, cluster)
closing_sus = Allocation.objects.expiring_service_units(account, cluster)

Check notice on line 58 in keystone_api/apps/allocations/tasks/limits.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

keystone_api/apps/allocations/tasks/limits.py#L58

'Allocation' may be undefined, or defined from star imports: apps.allocations.models, apps.users.models (F405)
active_sus = Allocation.objects.active_service_units(account, cluster)

Check notice on line 59 in keystone_api/apps/allocations/tasks/limits.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

keystone_api/apps/allocations/tasks/limits.py#L59

'Allocation' may be undefined, or defined from star imports: apps.allocations.models, apps.users.models (F405)

# Determine the historical contribution to the current limit
Expand Down Expand Up @@ -91,13 +91,12 @@ def update_limit_for_account(account: ResearchGroup, cluster: Cluster) -> None:
log.warning(f"The current usage is somehow higher than the limit for {account.name}!")

# Set the new account usage limit using the updated historical usage after closing any expired allocations
updated_historical_usage = Allocation.objects.updated_historical_usage(account, cluster)
updated_historical_usage = Allocation.objects.historical_usage(account, cluster)

Check notice on line 94 in keystone_api/apps/allocations/tasks/limits.py

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

keystone_api/apps/allocations/tasks/limits.py#L94

'Allocation' may be undefined, or defined from star imports: apps.allocations.models, apps.users.models (F405)
updated_limit = updated_historical_usage + active_sus
slurm.set_cluster_limit(account.name, cluster.name, updated_limit)

# Log summary of changes during limits update for this Slurm account on this cluster
log.debug(f"Summary of limits update for {account.name} on {cluster.name}:\n"
f"> Approved allocations found: {Allocation.objects.approved_allocations(account, cluster).count()}\n"
f"> Service units from active allocations: {active_sus}\n"
f"> Service units from closing allocations: {closing_sus}\n"
f"> {closing_summary}"
Expand Down

0 comments on commit 898f403

Please sign in to comment.