diff --git a/atdb/docs/ATDB-LDV Data Model.png b/atdb/docs/ATDB-LDV Data Model.png index ed9355872856acd73a88bd7f901c586cafd828d0..8a58bbc8c7a37bcd940402b5b448ad438f68634f 100644 Binary files a/atdb/docs/ATDB-LDV Data Model.png and b/atdb/docs/ATDB-LDV Data Model.png differ diff --git a/atdb/taskdatabase/migrations/0004_auto_20210330_1420.py b/atdb/taskdatabase/migrations/0004_auto_20210330_1420.py new file mode 100644 index 0000000000000000000000000000000000000000..b1392e213bd26e3a198ccef07d2593259028dd5e --- /dev/null +++ b/atdb/taskdatabase/migrations/0004_auto_20210330_1420.py @@ -0,0 +1,44 @@ +# Generated by Django 3.1.4 on 2021-03-30 12:20 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('taskdatabase', '0003_auto_20210301_1206'), + ] + + operations = [ + migrations.CreateModel( + name='Job', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('type', models.CharField(blank=True, default=None, max_length=20, null=True)), + ('task_id', models.IntegerField(blank=True, null=True)), + ('job_id', models.IntegerField(blank=True, null=True)), + ('metadata', models.JSONField(blank=True, null=True)), + ], + ), + migrations.AddField( + model_name='logentry', + name='service', + field=models.CharField(blank=True, max_length=30, null=True), + ), + migrations.AddField( + model_name='logentry', + name='size_processed', + field=models.PositiveBigIntegerField(blank=True, default=0, null=True), + ), + migrations.AddField( + model_name='workflow', + name='oi_size_fraction', + field=models.FloatField(blank=True, null=True), + ), + migrations.AlterField( + model_name='task', + name='creationTime', + field=models.DateTimeField(blank=True, default=datetime.datetime.utcnow, verbose_name='CreationTime'), + ), + ] diff --git a/atdb/taskdatabase/migrations/0005_auto_20210330_1437.py b/atdb/taskdatabase/migrations/0005_auto_20210330_1437.py new file mode 100644 index 0000000000000000000000000000000000000000..b370161a50ab63a0a9373fc2e68ea303242a72d8 --- /dev/null +++ b/atdb/taskdatabase/migrations/0005_auto_20210330_1437.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2021-03-30 12:37 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('taskdatabase', '0004_auto_20210330_1420'), + ] + + operations = [ + migrations.AlterField( + model_name='job', + name='type', + field=models.CharField(blank=True, db_index=True, default=None, max_length=20, null=True), + ), + ] diff --git a/atdb/taskdatabase/models.py b/atdb/taskdatabase/models.py index f548052d308dc48ababf163b1caa2668dd34daa1..328dddffef45323b6d0f41351403a3907fb93c4b 100644 --- a/atdb/taskdatabase/models.py +++ b/atdb/taskdatabase/models.py @@ -11,6 +11,7 @@ class Workflow(models.Model): repository = models.CharField(max_length=100, blank=True, null=True) commit_id = models.CharField(max_length=15, blank=True, null=True) path = models.CharField(max_length=100, blank=True, null=True) + oi_size_fraction = models.FloatField(blank=True, null=True) def __str__(self): return str(self.id) @@ -61,11 +62,12 @@ class LogEntry(models.Model): cpu_cycles = models.IntegerField(null=True,blank=True) wall_clock_time = models.IntegerField(null=True,blank=True) url_to_log_file = models.CharField(max_length=100, blank=True, null=True) + service = models.CharField(max_length=30, blank=True, null=True) step_name = models.CharField(max_length=30, blank=True, null=True) timestamp = models.DateTimeField(blank=True, null=True) status = models.CharField(max_length=50,default="defined", blank=True, null=True) description = models.CharField(max_length=100, blank=True, null=True) - + size_processed = models.PositiveBigIntegerField(default=0, null=True, blank=True) # relationships task = models.ForeignKey(Task, related_name='log_entries', on_delete=models.CASCADE, null=False) @@ -92,4 +94,15 @@ class Configuration(models.Model): # the representation of the value in the REST API def __str__(self): - return str(self.key) \ No newline at end of file + return str(self.key) + + +class Job(models.Model): + type = models.CharField(db_index=True, max_length=20, default=None,null=True, blank=True) + task_id = models.IntegerField(null=True, blank=True) + job_id = models.IntegerField(null=True, blank=True) + metadata = models.JSONField(null=True, blank=True) + + # the representation of the value in the REST API + def __str__(self): + return str(self.id) \ No newline at end of file diff --git a/atdb/taskdatabase/serializers.py b/atdb/taskdatabase/serializers.py index fe2de6ec05952854ca15e2b861e962c5c09268ac..538c1de5d0aa573e5f13e2ca5081c54a812f5013 100644 --- a/atdb/taskdatabase/serializers.py +++ b/atdb/taskdatabase/serializers.py @@ -1,5 +1,5 @@ from rest_framework import serializers -from .models import Status, Task, Workflow, LogEntry, Configuration +from .models import Status, Task, Workflow, LogEntry, Configuration, Job @@ -154,3 +154,10 @@ class ConfigurationSerializer(serializers.ModelSerializer): class Meta: model = Configuration fields = "__all__" + + +class JobSerializer(serializers.ModelSerializer): + + class Meta: + model = Job + fields = "__all__" diff --git a/atdb/taskdatabase/templates/taskdatabase/details/workflow_details.html b/atdb/taskdatabase/templates/taskdatabase/details/workflow_details.html index aa202aa199d755824ff1be9ec3124ef5ea9617e0..175df6102bafb1d115d55dc3c6437b868420c5f7 100644 --- a/atdb/taskdatabase/templates/taskdatabase/details/workflow_details.html +++ b/atdb/taskdatabase/templates/taskdatabase/details/workflow_details.html @@ -12,6 +12,7 @@ <tr><td><b>repository</b></td><td><a href="{{ workflow.repository }}" target="_blank">{{ workflow.repository }} </a></td></tr> <tr><td><b>commit_id</b></td><td>{{ workflow.commit_id }}</td></tr> <tr><td><b>path</b></td><td>{{ workflow.path }}</td></tr> + <tr><td><b>oi_size_fraction</b></td><td>{{ workflow.oi_size_fraction }}</td></tr> <tr> <td><b>workflows list</b></td><td><a href="{% url 'workflows-api' %}" class="btn btn-secondary btn-sm" role="button" target="_blank">REST API</a></td> </tr> diff --git a/atdb/taskdatabase/templates/taskdatabase/index.html b/atdb/taskdatabase/templates/taskdatabase/index.html index 1e664eb3a9c1b9563d560a6437295dba8e89a85e..271aae411839e98cea70a8d8df85d06ddafb358a 100644 --- a/atdb/taskdatabase/templates/taskdatabase/index.html +++ b/atdb/taskdatabase/templates/taskdatabase/index.html @@ -80,7 +80,7 @@ {% include 'taskdatabase/pagination.html' %} </div> </div> - <p class="footer"> Version 1.0.0 (26 mar 2021 - 19:00) + <p class="footer"> Version 1.0.0 (30 mar 2021 - 14:00) </div> diff --git a/atdb/taskdatabase/urls.py b/atdb/taskdatabase/urls.py index 6f92d89e3e090977629adf212bf9e3fd69b1d20f..052b477d21516b1b08f740567040f70a186a84f7 100644 --- a/atdb/taskdatabase/urls.py +++ b/atdb/taskdatabase/urls.py @@ -43,6 +43,9 @@ urlpatterns = [ path('configuration/', views.ConfigurationListViewAPI.as_view()), path('configuration/<int:pk>/', views.ConfigurationDetailsViewAPI.as_view(), name='configuration-detail-view-api'), + path('jobs/', views.JobListViewAPI.as_view()), + path('jobs/<int:pk>/', views.JobDetailsViewAPI.as_view(), name='job-detail-view-api'), + # --- custom requests --- # /atdb/get_size?status__in=defined,staged path('tasks/get_size', views.GetSizeView.as_view(), name='get-size-view'), diff --git a/atdb/taskdatabase/views.py b/atdb/taskdatabase/views.py index b80e33408edb868fbeae8108f8e8a17bc3b8c554..a9c06528882f1940353062585f988ed95546a2b3 100644 --- a/atdb/taskdatabase/views.py +++ b/atdb/taskdatabase/views.py @@ -23,7 +23,7 @@ from django_tables2 import SingleTableView from django.conf import settings -from .models import Task, Status, Workflow, LogEntry, Configuration +from .models import Task, Status, Workflow, LogEntry, Configuration, Job from .tables import TaskTable from django.db.models import Q @@ -33,7 +33,8 @@ from .serializers import \ TaskReadSerializerFast, \ WorkflowSerializer,\ LogEntrySerializer,\ - ConfigurationSerializer + ConfigurationSerializer,\ + JobSerializer from .services import algorithms @@ -104,6 +105,17 @@ class ConfigurationFilter(filters.FilterSet): 'key': ['exact', 'icontains'], } +class JobFilter(filters.FilterSet): + + class Meta: + model = Job + + fields = { + 'type': ['exact', 'icontains'], + 'task_id': ['exact'], + 'job_id': ['exact'], + } + # ---------- Tables2 Views (experimental) ----------- # implementation with tables2: http://localhost:8000/atdb/tables2 class QueryView(SingleTableMixin, FilterView): @@ -421,6 +433,21 @@ class ConfigurationDetailsViewAPI(generics.RetrieveUpdateDestroyAPIView): queryset = Configuration.objects.all() serializer_class = ConfigurationSerializer +# example: /atdb/job/ +class JobListViewAPI(generics.ListCreateAPIView): + model = Job + queryset = Job.objects.all() + serializer_class = JobSerializer + + filter_backends = (filters.DjangoFilterBackend,) + filter_class = JobFilter + + +# example: /atdb/job/5/ +class JobDetailsViewAPI(generics.RetrieveUpdateDestroyAPIView): + model = Job + queryset = Job.objects.all() + serializer_class = JobSerializer # --- controller resources, triggered by a button in the GUI or directoy with a URL --- # set task status to 'new_status' - called from the GUI