From 6d4f1df27e7160cc8c7a0afef9ce213ed9b8aac5 Mon Sep 17 00:00:00 2001 From: Nico Vermaas <vermaas@astron.nl> Date: Thu, 28 Jan 2021 11:51:59 +0100 Subject: [PATCH] database changes - skip -> resume - added task.metrics --- .../migrations/0002_auto_20210128_1120.py | 32 +++++++++++++++++++ atdb/taskdatabase/models.py | 5 +-- atdb/taskdatabase/serializers.py | 4 +-- .../templates/taskdatabase/index.html | 2 +- atdb/taskdatabase/views.py | 7 ++++ 5 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 atdb/taskdatabase/migrations/0002_auto_20210128_1120.py diff --git a/atdb/taskdatabase/migrations/0002_auto_20210128_1120.py b/atdb/taskdatabase/migrations/0002_auto_20210128_1120.py new file mode 100644 index 00000000..498ff177 --- /dev/null +++ b/atdb/taskdatabase/migrations/0002_auto_20210128_1120.py @@ -0,0 +1,32 @@ +# Generated by Django 3.1.4 on 2021-01-28 10:20 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('taskdatabase', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='task', + name='skip', + ), + migrations.AddField( + model_name='task', + name='metrics', + field=models.JSONField(blank=True, null=True), + ), + migrations.AddField( + model_name='task', + name='resume', + field=models.BooleanField(default=True), + ), + migrations.AlterField( + model_name='task', + name='stage_request_id', + field=models.IntegerField(null=True), + ), + ] diff --git a/atdb/taskdatabase/models.py b/atdb/taskdatabase/models.py index 80397b46..eb775c2a 100644 --- a/atdb/taskdatabase/models.py +++ b/atdb/taskdatabase/models.py @@ -27,18 +27,19 @@ class Task(models.Model): new_workflow_id = models.CharField(max_length=15, blank=True, null=True) new_workflow_uri = models.CharField(max_length=100, blank=True, null=True) - skip = models.BooleanField(default=False) + resume = models.BooleanField(default=True) creationTime = models.DateTimeField(default=datetime.utcnow, blank=True) priority = models.IntegerField(null=True) purge_policy = models.CharField(max_length=5, default="no", blank=True, null=True) - stage_request_id = models.IntegerField(default=0,null=True) + stage_request_id = models.IntegerField(null=True) # LOFAR properties project = models.CharField(max_length=100, blank=True, null=True, default="unknown") sas_id = models.CharField(max_length=15, blank=True, null=True) inputs = models.JSONField(null=True, blank=True) outputs = models.JSONField(null=True, blank=True) + metrics = models.JSONField(null=True, blank=True) # relationships workflow = models.ForeignKey(Workflow, related_name='tasks', on_delete=models.SET_NULL, null=True, blank=True) diff --git a/atdb/taskdatabase/serializers.py b/atdb/taskdatabase/serializers.py index f08f750e..d09d1109 100644 --- a/atdb/taskdatabase/serializers.py +++ b/atdb/taskdatabase/serializers.py @@ -44,11 +44,11 @@ class TaskSerializer(serializers.ModelSerializer): class Meta: model = Task fields = ('id','task_type','taskID','filter','predecessor','successors', - 'project','sas_id','priority','purge_policy','skip', + 'project','sas_id','priority','purge_policy','resume', 'new_workflow_id','new_workflow_uri','workflow', 'stage_request_id', 'status','new_status', - 'inputs','outputs','status_history', + 'inputs','outputs','metrics','status_history', 'log_entries' ) diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index 74caa9d9..d4dd04e6 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -44,7 +44,7 @@ </div> {% include 'taskdatabase/pagination.html' %} </div> - <p class="footer"> Version 1.0.0 (26 jan 2021 - 10:00) + <p class="footer"> Version 1.0.0 (28 jan 2021 - 11:00) <script type="text/javascript"> (function(seconds) { var refresh, diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py index e35e6679..39779382 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -189,6 +189,13 @@ class LogEntryDetailsViewAPI(generics.RetrieveUpdateDestroyAPIView): queryset = LogEntry.objects.all() serializer_class = LogEntrySerializer + # overriding the update, because the status that comes in with the LogEntry + # also needs to propagate to the task.new_status + def perform_update(self, serializer): + log_entry = serializer.save() + task = log_entry.task + task.new_status = log_entry.status + task.save() # --- controller resources, triggered by a button in the GUI or directoy with a URL --- # set task status to 'new_status' - called from the GUI -- GitLab