Skip to content
This repository has been archived by the owner on May 14, 2024. It is now read-only.

Commit

Permalink
Use billing instead of cpu/gpu for TRES limit (#363)
Browse files Browse the repository at this point in the history
* use billing instead of cpu/gpu for TRES limit

* getting the lock state should look for billing as well
  • Loading branch information
Comeani authored Feb 28, 2024
1 parent 1c099bf commit 467e563
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions bank/system/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def get_locked_state(self, cluster: str) -> bool:
raise ClusterNotFoundError(f'Cluster {cluster} is not configured with Slurm')

cmd = f'sacctmgr -n -P show assoc account={self.account_name} format=GrpTresRunMins clusters={cluster}'
return 'cpu=0' in ShellCmd(cmd).out
return 'billing=0' in ShellCmd(cmd).out

def set_locked_state(self, lock_state: bool, cluster: str) -> None:
"""Lock or unlock the current slurm account
Expand All @@ -146,10 +146,7 @@ def set_locked_state(self, lock_state: bool, cluster: str) -> None:
raise ClusterNotFoundError(f'Cluster {cluster} is not configured with Slurm')

lock_state_int = 0 if lock_state else -1
ShellCmd(f'sacctmgr -i modify account where account={self.account_name} cluster={cluster} '
f'set GrpTresRunMins=cpu={lock_state_int}').raise_if_err()
ShellCmd(f'sacctmgr -i modify account where account={self.account_name} cluster={cluster} '
f'set GrpTresRunMins=gres/gpu={lock_state_int}').raise_if_err()
ShellCmd(f'sacctmgr -i modify account where account={self.account_name} cluster={cluster} set GrpTresRunMins=billing={lock_state_int}').raise_if_err()

def get_cluster_usage_per_user(self, cluster: str, start: date, end: date, in_hours: bool = True) -> Dict[str, int]:
"""Return the raw account usage per user on a given cluster
Expand Down

0 comments on commit 467e563

Please sign in to comment.