Skip to content
Snippets Groups Projects
Commit 4916fcf7 authored by Nico Vermaas's avatar Nico Vermaas
Browse files

Merge branch 'SDC-782-resource-dashboard-change' into 'master'

Sdc 782 resource dashboard change

See merge request !272
parents 7d91617d 78137a33
No related branches found
No related tags found
1 merge request!272Sdc 782 resource dashboard change
Pipeline #42315 passed
...@@ -4,6 +4,9 @@ from django.utils import timezone ...@@ -4,6 +4,9 @@ from django.utils import timezone
from django.utils.timezone import datetime, timedelta from django.utils.timezone import datetime, timedelta
from django.conf import settings from django.conf import settings
import logging
logger = logging.getLogger(__name__)
# constants # constants
datetime_format_string = '%Y-%m-%dT%H:%M:%SZ' datetime_format_string = '%Y-%m-%dT%H:%M:%SZ'
...@@ -226,7 +229,42 @@ class LogEntry(models.Model): ...@@ -226,7 +229,42 @@ class LogEntry(models.Model):
task = models.ForeignKey(Task, related_name='log_entries', on_delete=models.CASCADE, null=False) task = models.ForeignKey(Task, related_name='log_entries', on_delete=models.CASCADE, null=False)
def __str__(self): def __str__(self):
return str(self.id)+ ' - '+ str(self.task)+' - '+self.status return str(self.id)+ ' - '+ str(self.task)+' - '+self.status +' ('+self.step_name+')'
def save(self, *args, **kwargs):
#override save to check how long this task has been in this state.
try:
# if this logentry already has a wall_clock_time, then don't change it.
if not self.wall_clock_time:
# gather all entries for this task, to discover the previous one.
entries_for_this_task = LogEntry.objects.filter(task=self.task).order_by("-timestamp")
# remove entries from the list, including 'this', so that the latest remaining is the previous entry.
for entry in entries_for_this_task:
entries_for_this_task = entries_for_this_task.exclude(id=entry.id)
if entry == self:
break
try:
latest_entry_before_self = entries_for_this_task.latest('timestamp')
previous_timestamp = latest_entry_before_self.timestamp
except:
# if no previous entry exists, then use the timestamp from the task.
previous_timestamp = self.task.creationTime
dt = (self.timestamp - previous_timestamp).seconds
message = "logentry for task "+str(self.task.id)+", to "+self.status + " took " + str(dt) + " seconds"
logger.info(message)
self.wall_clock_time = dt
except Exception as e:
print(e)
finally:
# finally save the Monitor info itself also
super(LogEntry, self).save(*args, **kwargs)
class Status(models.Model): class Status(models.Model):
......
...@@ -608,7 +608,7 @@ def construct_logs_per_workflow_html_version1(log_records): ...@@ -608,7 +608,7 @@ def construct_logs_per_workflow_html_version1(log_records):
def construct_logs_per_workflow_html(request, workflow_results): def construct_logs_per_workflow_html(request, workflow_results):
results = "<p>Resources used per step per workflow: <b>cpu_cycles/wall_clock_time</b></p>" results = "<p>Resources used per step per workflow: <b>cpu_cycles/wall_clock_time (seconds)</b></p>"
# construct the header # construct the header
header = "<th>Workflow</th>" header = "<th>Workflow</th>"
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
{% include 'taskdatabase/pagination.html' %} {% include 'taskdatabase/pagination.html' %}
</div> </div>
</div> </div>
<p class="footer"> Version 23 December 2022 - 8:00 <p class="footer"> Version 10 Januari 2022 - 15:00
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment