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

switched off new functionality for database deployment only

parent e3c9bc6b
Branches
No related tags found
1 merge request!339SDC-1188 - STEP 1 of 3 (the database)
Pipeline #71895 failed
...@@ -204,7 +204,8 @@ class Task(models.Model): ...@@ -204,7 +204,8 @@ class Task(models.Model):
self.calculated_qualities = qualities.calculate_qualities(self, tasks_for_this_sasid, quality_thresholds) self.calculated_qualities = qualities.calculate_qualities(self, tasks_for_this_sasid, quality_thresholds)
# make sure that every task has an activity (backward compatibility) # make sure that every task has an activity (backward compatibility)
associate_task_with_activity(self) # TODO: uncomment to enable SDC-1188 functionality
#associate_task_with_activity(self)
# remark: # remark:
# a post_save signal is triggered by this save() # a post_save signal is triggered by this save()
...@@ -340,21 +341,24 @@ class Task(models.Model): ...@@ -340,21 +341,24 @@ class Task(models.Model):
except: except:
return None return None
# keep the old mechanism in comments to test/evaluate, remove later when it works # keep the old mechanism in comments to test/evaluate
# @property # TODO: remove when it is no longer used by the GUI
# def sas_id_has_archived(self): # --- <CUT> ---
# """ @property
# check if any task belonging to this sas_id already has an output SAS_ID at the LTA def sas_id_has_archived(self):
# """ """
# try: check if any task belonging to this sas_id already has an output SAS_ID at the LTA
# for task in Task.objects.filter(sas_id=self.sas_id): """
# try: try:
# if task.archive['sas_id_archived']: for task in Task.objects.filter(sas_id=self.sas_id):
# return task.archive['sas_id_archived'] try:
# except: if task.archive['sas_id_archived']:
# pass return task.archive['sas_id_archived']
# except: except:
# return None pass
except:
return None
# --- </CUT> ---
@property @property
def path_to_lta(self): def path_to_lta(self):
...@@ -367,92 +371,96 @@ class Task(models.Model): ...@@ -367,92 +371,96 @@ class Task(models.Model):
return None return None
# keep the old mechanism in comments to test/evaluate, remove later when it works # keep the old mechanism in comments to test/evaluate, remove later when it works
# @property # TODO: remove when it is no longer used by the GUI
# def sasid_path_to_lta(self): # ---- <CUT> ----
# """ @property
# check if any task belonging to this sas_id already has a 'path_to_lta' setting def sasid_path_to_lta(self):
# """ """
# try: check if any task belonging to this sas_id already has a 'path_to_lta' setting
# for task in Task.objects.filter(sas_id=self.sas_id): """
# try: try:
# if task.archive['path_to_lta']: for task in Task.objects.filter(sas_id=self.sas_id):
# return task.archive['path_to_lta'] try:
# except: if task.archive['path_to_lta']:
# # if 'path_to_lta' is not found, or 'archive' is empty, continue to the next task return task.archive['path_to_lta']
# pass except:
# except: # if 'path_to_lta' is not found, or 'archive' is empty, continue to the next task
# return None pass
except:
return None
#
# @property @property
# def sasid_is_verified(self): def sasid_is_verified(self):
# for task in Task.objects.filter(sas_id=self.sas_id): for task in Task.objects.filter(sas_id=self.sas_id):
# if task.status not in verified_statusses: if task.status not in verified_statusses:
# return False return False
# return True return True
#
# @property @property
# def sasid_finished_fraction(self): def sasid_finished_fraction(self):
# size_archived = 0 size_archived = 0
# size_remaining = 0 size_remaining = 0
# total_size = 0 total_size = 0
#
# tasks = Task.objects.filter(sas_id=self.sas_id) tasks = Task.objects.filter(sas_id=self.sas_id)
#
# for task in tasks: for task in tasks:
# if task.status == State.FINISHED.value: if task.status == State.FINISHED.value:
# size_archived = size_archived + task.size_to_process size_archived = size_archived + task.size_to_process
# else: else:
# size_remaining = size_remaining + task.size_to_process size_remaining = size_remaining + task.size_to_process
# total_size = total_size + task.size_to_process total_size = total_size + task.size_to_process
#
# finished = {} finished = {}
# try: try:
# finished['fraction'] = round((size_archived / (size_remaining + size_archived)) * 100) finished['fraction'] = round((size_archived / (size_remaining + size_archived)) * 100)
# except: except:
# finished['fraction'] = -1 finished['fraction'] = -1
#
# finished['total_size'] = total_size finished['total_size'] = total_size
# finished['remaining'] = size_remaining finished['remaining'] = size_remaining
#
# return finished return finished
#
# @property @property
# def sasid_ingested_fraction(self): def sasid_ingested_fraction(self):
# """ """
# This 'property' of a task returns the fraction of queued/ingested tasks per SAS_ID This 'property' of a task returns the fraction of queued/ingested tasks per SAS_ID
# and a list of statusses of other tasks belonging to the same SAS_ID. and a list of statusses of other tasks belonging to the same SAS_ID.
# It is implemented as 'property', because then it can be used in html pages like this: It is implemented as 'property', because then it can be used in html pages like this:
# <td>{{ task.sasid_ingested_fraction.status }}</td> <td>{{ task.sasid_ingested_fraction.status }}</td>
# <td>{{ task.sasid_ingested_fraction.completion }}%</td> <td>{{ task.sasid_ingested_fraction.completion }}%</td>
#
# A selection of statusses are considered 'queued', and another selection is considered 'ingested'. A selection of statusses are considered 'queued', and another selection is considered 'ingested'.
# The division of those 2 are returned as a 'completed %'. The division of those 2 are returned as a 'completed %'.
# A limited list of statusses for the other tasks that belong to this SAS_ID is also returned. A limited list of statusses for the other tasks that belong to this SAS_ID is also returned.
#
# """ """
# result = {} result = {}
# statusses = {'scrubbed': 0, 'archiving': 0, 'archived': 0, 'finishing': 0, 'finished': 0, statusses = {'scrubbed': 0, 'archiving': 0, 'archived': 0, 'finishing': 0, 'finished': 0,
# 'suspended': 0,'discarded': 0, 'archived_failed': 0, 'finished_failed': 0} 'suspended': 0,'discarded': 0, 'archived_failed': 0, 'finished_failed': 0}
#
# tasks = Task.objects.filter(sas_id=self.sas_id) tasks = Task.objects.filter(sas_id=self.sas_id)
#
# for task in tasks: for task in tasks:
# try: try:
# statusses[task.status] += 1 statusses[task.status] += 1
# except: except:
# pass pass
#
# incomplete = int(statusses['scrubbed']) + int(statusses['archiving']) + int(statusses['finishing']) +\ incomplete = int(statusses['scrubbed']) + int(statusses['archiving']) + int(statusses['finishing']) +\
# int(statusses['suspended']) + int(statusses['archived_failed']) + int(statusses['finished_failed']) int(statusses['suspended']) + int(statusses['archived_failed']) + int(statusses['finished_failed'])
# complete = int(statusses['archived']) + int(statusses['finished']) complete = int(statusses['archived']) + int(statusses['finished'])
# completion = round(complete / (incomplete + complete) * 100) completion = round(complete / (incomplete + complete) * 100)
#
# non_zero_statusses = {key: value for key, value in statusses.items() if value != 0} non_zero_statusses = {key: value for key, value in statusses.items() if value != 0}
#
# result['status'] = non_zero_statusses result['status'] = non_zero_statusses
# result['completion'] = completion result['completion'] = completion
# return result return result
# ---- </CUT> ----
@property @property
def task_type_join(self): def task_type_join(self):
......
...@@ -68,15 +68,16 @@ def calculate_finished_fraction(this_task): ...@@ -68,15 +68,16 @@ def calculate_finished_fraction(this_task):
def update_activity(task): def update_activity(task):
""" """
The activity (SAS_ID level) is updated whenever a task change status. The activity (SAS_ID level) is updated when a task changes status.
Depending on the type of status change, certain calculations and updates are performed. Depending on the type of status change, certain calculations and updates are performed.
Doing this on status change, instead of on-the-fly when a user enters a page, balances the load. Doing this on status change, instead of on-the-fly when a user enters a page, balances the load
and improves overall performance
- to 'ARCHIVING, ARCHIVED, FINISHED' : check for incoming/existing 'archive' json from archiver - to 'ARCHIVING, ARCHIVED, FINISHED' : check for incoming/existing 'archive' json from archiver
- to STORED : calculate quality - to STORED : calculate quality
- to _FAILED : calculate finished_fraction
- to SCRUBBED, ARCHIVING, ARCHIVED, FINISHED : calculate ingested_fraction - to SCRUBBED, ARCHIVING, ARCHIVED, FINISHED : calculate ingested_fraction
- always : calc 'verified' - to _FAILED : calculate finished_fraction
- always : determine if a task is in a 'verified' status
""" """
logger.info(f'update_activity for task {task.id} with sas_id {task.sas_id} and status {task.status}') logger.info(f'update_activity for task {task.id} with sas_id {task.sas_id} and status {task.status}')
......
...@@ -69,7 +69,8 @@ def handle_post_save(sender, **kwargs): ...@@ -69,7 +69,8 @@ def handle_post_save(sender, **kwargs):
""" """
task = kwargs.get('instance') task = kwargs.get('instance')
update_activity(task) # TODO: uncomment to enable SDC-1188 functionality
# update_activity(task)
def connect_signals(): def connect_signals():
......
...@@ -37,13 +37,14 @@ ...@@ -37,13 +37,14 @@
<td>{{ task.filter }} </td> <td>{{ task.filter }} </td>
<!-- keep the old mechanism in comments to test/evaluate, remove later when it works --> <!-- keep the old mechanism in comments to test/evaluate, remove later when it works -->
<!--
<td>{{ task.sasid_finished_fraction.fraction }}% of {{ task.sasid_finished_fraction.total_size|filesizeformat }}</td> <td>{{ task.sasid_finished_fraction.fraction }}% of {{ task.sasid_finished_fraction.total_size|filesizeformat }}</td>
<td>{{ task.size_to_process|filesizeformat }} / {{ task.sasid_finished_fraction.remaining|filesizeformat }}</td> <td>{{ task.size_to_process|filesizeformat }} / {{ task.sasid_finished_fraction.remaining|filesizeformat }}</td>
-->
<!-- new activity mechanism, to enable SDC-1188
<td>{{ task.activity.finished_fraction }}% of {{ task.activity.total_size|filesizeformat }}</td> <td>{{ task.activity.finished_fraction }}% of {{ task.activity.total_size|filesizeformat }}</td>
<td>{{ task.size_to_process|filesizeformat }} / {{ task.activity.remaining|filesizeformat }}</td> <td>{{ task.size_to_process|filesizeformat }} / {{ task.activity.remaining|filesizeformat }}</td>
-->
<td> <td>
{% include "taskdatabase/failures/retry_buttons.html" %} {% include "taskdatabase/failures/retry_buttons.html" %}
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</td> </td>
<!-- keep the old mechanism in comments to test/evaluate, remove later when it works --> <!-- keep the old mechanism in comments to test/evaluate, remove later when it works -->
<!--
<td>{{ task.sasid_ingested_fraction.status }}</td> <td>{{ task.sasid_ingested_fraction.status }}</td>
<td>{{ task.sasid_ingested_fraction.completion }}%</td> <td>{{ task.sasid_ingested_fraction.completion }}%</td>
...@@ -39,7 +39,8 @@ ...@@ -39,7 +39,8 @@
- -
{% endif %} {% endif %}
</td> </td>
-->
<!-- new activity mechanism, to enable SDC-1188
<td>{{ task.activity.ingestq_status }}</td> <td>{{ task.activity.ingestq_status }}</td>
<td>{{ task.activity.ingested_fraction }}%</td> <td>{{ task.activity.ingested_fraction }}%</td>
<td> <td>
...@@ -52,6 +53,7 @@ ...@@ -52,6 +53,7 @@
- -
{% endif %} {% endif %}
</td> </td>
-->
</tr> </tr>
</div> </div>
{% endif %} {% endif %}
......
...@@ -70,10 +70,12 @@ ...@@ -70,10 +70,12 @@
</td> </td>
<!-- keep the old mechanism in comments to test/evaluate, remove later when it works --> <!-- keep the old mechanism in comments to test/evaluate, remove later when it works -->
<!--
<td class="{{ task.calculated_qualities.per_sasid }}">{{ task.calculated_qualities.per_sasid|default_if_none:"-" }} (old)</td> <td class="{{ task.calculated_qualities.per_sasid }}">{{ task.calculated_qualities.per_sasid|default_if_none:"-" }} (old)</td>
-->
<!-- new activity mechanism, to enable SDC-1188
<td class="{{ task.activity.calculated_quality }}">{{ task.activity.calculated_quality|default_if_none:"-" }}</td> <td class="{{ task.activity.calculated_quality }}">{{ task.activity.calculated_quality|default_if_none:"-" }}</td>
-->
<td class="{{ task.quality }}">{{ task.quality|default_if_none:"-" }}</td> <td class="{{ task.quality }}">{{ task.quality|default_if_none:"-" }}</td>
<td>{% include "taskdatabase/validation/validation_buttons.html" %}</td> <td>{% include "taskdatabase/validation/validation_buttons.html" %}</td>
<td><a href="{% url 'task-discard-view-sasid' task.pk 'discard' my_tasks.number %}" class="btn btn-danger btn-sm" role="button"><i class="fas fa-trash-alt"></i></a></td> <td><a href="{% url 'task-discard-view-sasid' task.pk 'discard' my_tasks.number %}" class="btn btn-danger btn-sm" role="button"><i class="fas fa-trash-alt"></i></a></td>
......
<!-- keep the old mechanism in comments to test/evaluate, remove later when it works --> <!-- keep the old mechanism in comments to test/evaluate, remove later when it works -->
<!--
{% if task.sasid_is_verified %} {% if task.sasid_is_verified %}
<a href="{% url 'task-validate-sasid' task.pk 'poor' 'validated' my_tasks.number %}" class="btn btn-danger btn-sm" role="button"><i class="fas fa-check"></i> P</a> <a href="{% url 'task-validate-sasid' task.pk 'poor' 'validated' my_tasks.number %}" class="btn btn-danger btn-sm" role="button"><i class="fas fa-check"></i> P</a>
{% endif %} {% endif %}
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
{% if task.sasid_is_verified %} {% if task.sasid_is_verified %}
<a href="{% url 'task-validate-sasid' task.pk 'calculated' 'validated' my_tasks.number %}" class="btn btn-success btn-sm" role="button"><i class="fas fa-check"></i> Validate</a> <a href="{% url 'task-validate-sasid' task.pk 'calculated' 'validated' my_tasks.number %}" class="btn btn-success btn-sm" role="button"><i class="fas fa-check"></i> Validate</a>
{% endif %} {% endif %}
-->
<!-- new activity mechanism, to enable SDC-1188
{% if task.activity.is_verified %} {% if task.activity.is_verified %}
<a href="{% url 'task-validate-sasid' task.pk 'poor' 'validated' my_tasks.number %}" class="btn btn-danger btn-sm" role="button"><i class="fas fa-check"></i> P</a> <a href="{% url 'task-validate-sasid' task.pk 'poor' 'validated' my_tasks.number %}" class="btn btn-danger btn-sm" role="button"><i class="fas fa-check"></i> P</a>
{% endif %} {% endif %}
...@@ -32,3 +32,4 @@ ...@@ -32,3 +32,4 @@
{% if task.activity.is_verified %} {% if task.activity.is_verified %}
<a href="{% url 'task-validate-sasid' task.pk 'calculated' 'validated' my_tasks.number %}" class="btn btn-success btn-sm" role="button"><i class="fas fa-check"></i> Validate</a> <a href="{% url 'task-validate-sasid' task.pk 'calculated' 'validated' my_tasks.number %}" class="btn btn-success btn-sm" role="button"><i class="fas fa-check"></i> Validate</a>
{% endif %} {% endif %}
-->
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment