Skip to content

Commit

Permalink
usage unit
Browse files Browse the repository at this point in the history
  • Loading branch information
claire-peters committed Nov 16, 2023
1 parent bd87984 commit f53944e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,12 @@ <h3 class="d-inline"><i class="fas fa-users" aria-hidden="true"></i> Users in Al

<tbody>
{% for user in allocation_users %}
{% if user.unit not "CPU Hours" %}
{% user.usage_bytes as userusage %}
{% allocation.usage_exact as allocationusage %}
{% else %}
{% user.usage_bytes as userusage %}
{% endif %}
<tr status = "{{ user.status }}">
<td>{{ user.user.first_name }} {{ user.user.last_name }}</td>

Expand All @@ -471,20 +477,22 @@ <h3 class="d-inline"><i class="fas fa-users" aria-hidden="true"></i> Users in Al
{% else %}
<td class="text-info">{{ user.status.name }}</td>
{% endif %}
{% if user.usage_bytes == 0.0 %}
<td data-sort = "{{user.usage_bytes}}" name = "usage_bytes"> 0 bytes</td>
{% else %}
<td data-sort = "{{user.usage_bytes}}" name = "usage_bytes">{{ user.usage|floatformat:1 }}{{ user.unit }}</td>
{% endif %}
{% if allocation.usage_exact == None or allocation.usage_exact == 0 %}
<td>0</td>
<td data-sort = "{{userusage}}" name = "usage_bytes">
{% if userusage is None %}
0 {{ user.unit }}
{% else %}
{{ user.usage|floatformat:1 }}{{ user.unit }}
{% endif %}
</td>
{% if allocationusage == None or allocationusage == 0 %}
<td>0</td>
{% else %}
<td>{{user.usage_bytes|div:allocation.usage_exact|mul:100|floatformat:2 }}%</td>
<td>{{userusage|div:allocationusage|mul:100|floatformat:2 }}%</td>
{% endif %}
{% if "Cluster" in allocation.get_parent_resource.resource_type.name %}
{% cost_cpuhours user.usage as cost %}
{% if if user.unit not "CPU Hours" %}
{% cost_cpuhours userusage as cost %}
{% else %}
{% cost_bytes user.usage_bytes as cost %}
{% cost_bytes userusage as cost %}
{% endif %}
{% if cost %}
<td>{{ cost }}</td>
Expand Down
4 changes: 3 additions & 1 deletion coldfront/plugins/slurm/management/commands/slurm_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,7 @@ def handle(self, *args, **options):
continue
alloc_user, _ = allocation_obj.allocationuser_set.get_or_create(
user = get_user_model().objects.get(username=user_name),
defaults = {'status': auser_status_active}
defaults = {
'status': auser_status_active, "unit": "CPU Hours"
}
)
1 change: 1 addition & 0 deletions coldfront/plugins/xdmod/management/commands/xdmod_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def process_total_cpu_hours(self):
for user in s.allocationuser_set.all():
if user.user.username in usage_data:
user.usage = usage_data[user.user.username]
user.unit = "CPU Hours"
user.save()
if self.sync:
cpu_hours_attr = s.allocationattribute_set.get(
Expand Down

0 comments on commit f53944e

Please sign in to comment.