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

add summary file

parent dd770741
Branches
No related tags found
1 merge request!268SDC 779 add summary info
Pipeline #40906 passed
atdb/atdb/static/taskdatabase/ldvlogo_small.png

9.56 KiB

...@@ -49,6 +49,18 @@ def convert_quality_to_shortlist_for_template(task): ...@@ -49,6 +49,18 @@ def convert_quality_to_shortlist_for_template(task):
return list return list
def convert_summary_to_list_for_template(task):
list = []
try:
summary = task.quality_json['summary']
except Exception as err:
pass
return list
class Task(models.Model): class Task(models.Model):
...@@ -118,6 +130,29 @@ class Task(models.Model): ...@@ -118,6 +130,29 @@ class Task(models.Model):
except: except:
return False return False
@property
def has_plots(self):
try:
quality = self.outputs['quality']
plots = quality['plots']
if len(plots) > 0:
return True
else:
return False
except:
return False
@property
def has_summary(self):
try:
summary = self.outputs['quality']['summary']
return True
except:
return False
@property @property
def quality_json(self): def quality_json(self):
...@@ -169,6 +204,14 @@ class Task(models.Model): ...@@ -169,6 +204,14 @@ class Task(models.Model):
except: except:
return None return None
@property
def summary_as_list(self):
try:
q = convert_summary_to_list_for_template(self)
return q
except:
return None
class LogEntry(models.Model): class LogEntry(models.Model):
cpu_cycles = models.IntegerField(null=True,blank=True) cpu_cycles = models.IntegerField(null=True,blank=True)
wall_clock_time = models.IntegerField(null=True,blank=True) wall_clock_time = models.IntegerField(null=True,blank=True)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
Author: Nico Vermaas - Astron Author: Nico Vermaas - Astron
Description: Business logic for ATDB. These functions are called from the views (views.py). Description: Business logic for ATDB. These functions are called from the views (views.py).
""" """
import json
from datetime import datetime, timedelta from datetime import datetime, timedelta
from django.db.models import Q, Sum from django.db.models import Q, Sum
import logging import logging
...@@ -680,7 +680,6 @@ def unique_values_for_aggregation_key(queryset, aggregation_key): ...@@ -680,7 +680,6 @@ def unique_values_for_aggregation_key(queryset, aggregation_key):
def construct_inspectionplots(task): def construct_inspectionplots(task):
results = "" results = ""
quality_structure = task.quality_json
# translate the path to a url # translate the path to a url
try: try:
...@@ -703,3 +702,60 @@ def construct_inspectionplots(task): ...@@ -703,3 +702,60 @@ def construct_inspectionplots(task):
results += '<tr><td><a href="' + url + '" target="_blank">'+ basename + '</a></td></tr>' results += '<tr><td><a href="' + url + '" target="_blank">'+ basename + '</a></td></tr>'
return results return results
def construct_summary(task):
results = ""
# find the plots in the quality json structure
summary = task.quality_json["summary"]
#loaded = json.loads(summary)
for key in summary:
record = summary[key]
line = ''
line += '<tr style="background-color:#7EB1C4"><td colspan="3"><b>' + key + '</b></td></tr>'
line += '<th>input size</th>' \
'<th>output size</th>' \
'<th>size_ratio</th>'
line += '<tr>'
line += '<td>' + record['input_size_str'] + '</td>'
line += '<td>' + str(record['output_size']) + ' (' + record['output_size_str'] + ')</td>'
line += '<td>' + str(round(record['size_ratio'],3)) + '</td>'
line += '</tr>'
input_content = record['input_content']
line += '<th>Input Content</th>'
line += '<tr><td colspan="3">'
for filename in input_content:
line += filename + '\n'
line += '</td></tr>'
output_content = record['output_content']
line += '<th>Output Content</th>'
line += '<tr><td colspan="3">'
for filename in output_content:
line += filename + '\n'
line += '</td></tr>'
to_add = record['to_add']
if to_add:
line += '<th>to_add</th>'
line += '<tr><td colspan="3">'
for filename in to_add:
line += filename + '\n'
line += '</td></tr>'
to_delete = record['to_delete']
if to_delete:
line += '<th>to_delete</th>'
line += '<tr><td colspan="3">'
for filename in to_delete:
line += filename + '\n'
line += '</td></tr>'
results += line
return results
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
{% include 'taskdatabase/pagination.html' %} {% include 'taskdatabase/pagination.html' %}
</div> </div>
</div> </div>
<p class="footer"> Version 2 December 2022 - 13:00 <p class="footer"> Version 8 December 2022 - 7:00
</div> </div>
......
{% load static %}
{% block myBlock %}
<div class="container-fluid details-container">
<div class="card">
<div class="card-body">
<h4><img src="{% static 'taskdatabase/ldvlogo_small.png' %}" height="30" alt="summary">
Summary File (sas_id {{ task.sas_id }}) </h4>
<table class="table table-striped">
{{ my_summary | safe }}
</table>
</div>
</div>
</div>
{% endblock %}
{% include "taskdatabase/modal/modal_script.html" %}
{% include "taskdatabase/modal/modal.html" %}
\ No newline at end of file
...@@ -14,19 +14,36 @@ ...@@ -14,19 +14,36 @@
{% for value in task.quality_as_list %} {% for value in task.quality_as_list %}
<td>{{value}}</td> <td>{{value}}</td>
{% endfor %} {% endfor %}
<td>
<a class="open-modal btn btn-primary btn-sm" {% if task.has_plots %}
<td>
<a class="open-modal btn btn-primary btn-sm"
href="{% url 'inspection-plots' task.id my_tasks.number %}" href="{% url 'inspection-plots' task.id my_tasks.number %}"
data-popup-url="{% url 'inspection-plots' task.id my_tasks.number %}"> data-popup-url="{% url 'inspection-plots' task.id my_tasks.number %}">
<img src="{% static 'taskdatabase/surfsara.jpg' %}" height="20" alt="inspection plots"> <img src="{% static 'taskdatabase/surfsara.jpg' %}" height="20" alt="inspection plots">
</a>&nbsp; </a>&nbsp;
</td>
{% else %}
<td>-</td>
{% endif %}
{% if task.has_summary %}
<td>
<a class="open-modal btn btn-primary btn-sm"
href="{% url 'summary' task.id my_tasks.number %}"
data-popup-url="{% url 'summary' task.id my_tasks.number %}">
<img src="{% static 'taskdatabase/ldvlogo_small.png' %}" height="20" alt="summary"> SUM
</a>&nbsp;
</td> </td>
{% else %}
<td>-</td>
{% endif %}
{% else %} {% else %}
<td>-</td><td>-</td><td>-</td><td>-</td> <td>-</td><td>-</td><td>-</td><td>-</td><td>-</td>
{% endif %} {% endif %}
<td> <td>
{% if user.is_authenticated %} {% if user.is_authenticated %}
{% if task.get_quality_remarks_sasid %} {% if task.get_quality_remarks_sasid %}
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
<th>Sensitivity</th> <th>Sensitivity</th>
<th>Conditions</th> <th>Conditions</th>
<th>Plots</th> <th>Plots</th>
<th>Summary</th>
<th>Annotate</th> <th>Annotate</th>
<th>Quality</th> <th>Quality</th>
<th>Validate (choose a Q)</th> <th>Validate (choose a Q)</th>
......
...@@ -29,6 +29,7 @@ urlpatterns = [ ...@@ -29,6 +29,7 @@ urlpatterns = [
path('annotate_quality_sasid/<int:id>', views.AnnotateQualitySasId, name='annotate-quality-sasid'), path('annotate_quality_sasid/<int:id>', views.AnnotateQualitySasId, name='annotate-quality-sasid'),
path('annotate_quality_sasid/<int:id>/<page>', views.AnnotateQualitySasId, name='annotate-quality-sasid'), path('annotate_quality_sasid/<int:id>/<page>', views.AnnotateQualitySasId, name='annotate-quality-sasid'),
path('show_inspectionplots/<int:id>/<page>', views.ShowInspectionPlots, name='inspection-plots'), path('show_inspectionplots/<int:id>/<page>', views.ShowInspectionPlots, name='inspection-plots'),
path('show_summary/<int:id>/<page>', views.ShowSummary, name='summary'),
path('show-inputs/<int:id>/', views.ShowInputs, name='show-inputs'), path('show-inputs/<int:id>/', views.ShowInputs, name='show-inputs'),
path('show-outputs/<int:id>/', views.ShowOutputs, name='show-outputs'), path('show-outputs/<int:id>/', views.ShowOutputs, name='show-outputs'),
......
...@@ -604,6 +604,15 @@ def ShowInspectionPlots(request, id=0, page=0): ...@@ -604,6 +604,15 @@ def ShowInspectionPlots(request, id=0, page=0):
return render(request, "taskdatabase/validation/inspection_plots.html", {'task': task, 'my_plots': plots_html}) return render(request, "taskdatabase/validation/inspection_plots.html", {'task': task, 'my_plots': plots_html})
def ShowSummary(request, id=0, page=0):
# a GET means that the form should be presented to be filled in
task = Task.objects.get(id=id)
# convert the path to a url
summary_html = algorithms.construct_summary(task)
return render(request, "taskdatabase/validation/summary.html", {'task': task, 'my_summary': summary_html})
def ShowInputs(request, id): def ShowInputs(request, id):
task = Task.objects.get(id=id) task = Task.objects.get(id=id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment