Skip to content
Snippets Groups Projects
Commit 5b4c9288 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-320: store archive information for ingest-subtask-output-dataproducts only

parent b50999a2
No related branches found
No related tags found
2 merge requests!308Resolve TMSS-495,!306Resolve TMSS-320
...@@ -283,7 +283,7 @@ class TMSSsession(object): ...@@ -283,7 +283,7 @@ class TMSSsession(object):
if adler32_checksum: if adler32_checksum:
json_data['adler32_checksum'] = adler32_checksum json_data['adler32_checksum'] = adler32_checksum
response = self.session.post(url=self.get_full_url_for_path('dataproduct/%s/process_archive_information' % (dataproduct_id,)), json=json_data) response = self.session.post(url=self.get_full_url_for_path('dataproduct/%s/post_archive_information' % (dataproduct_id,)), json=json_data)
logger.info("post_dataproduct_archive_information: json_doc: %s response: %s", json_data, response.text) logger.info("post_dataproduct_archive_information: json_doc: %s response: %s", json_data, response.text)
if response.status_code == 201: if response.status_code == 201:
logger.info("created new template: %s", json.loads(response.text)['url']) logger.info("created new template: %s", json.loads(response.text)['url'])
......
...@@ -24,6 +24,7 @@ from lofar.common import isProductionEnvironment, isTestEnvironment ...@@ -24,6 +24,7 @@ from lofar.common import isProductionEnvironment, isTestEnvironment
from lofar.sas.tmss.tmss.tmssapp.viewsets.lofar_viewset import LOFARViewSet from lofar.sas.tmss.tmss.tmssapp.viewsets.lofar_viewset import LOFARViewSet
from lofar.sas.tmss.tmss.tmssapp import models from lofar.sas.tmss.tmss.tmssapp import models
from lofar.sas.tmss.tmss.tmssapp import serializers from lofar.sas.tmss.tmss.tmssapp import serializers
from lofar.sas.tmss.tmss.exceptions import TMSSException
from datetime import datetime from datetime import datetime
from lofar.common.json_utils import get_default_json_object_for_schema from lofar.common.json_utils import get_default_json_object_for_schema
...@@ -360,13 +361,17 @@ class DataproductViewSet(LOFARViewSet): ...@@ -360,13 +361,17 @@ class DataproductViewSet(LOFARViewSet):
from lofar.sas.tmss.tmss.tmssapp.adapters.sip import generate_sip_for_dataproduct from lofar.sas.tmss.tmss.tmssapp.adapters.sip import generate_sip_for_dataproduct
return HttpResponse(visualizer.visualize_sip(generate_sip_for_dataproduct(dataproduct)), content_type='image/svg+xml') return HttpResponse(visualizer.visualize_sip(generate_sip_for_dataproduct(dataproduct)), content_type='image/svg+xml')
@swagger_auto_schema(responses={200: 'The finished version of this subtask.', @swagger_auto_schema(responses={200: 'The updated dataproduct.',
403: 'forbidden', 403: 'forbidden',
500: 'The feedback of this subtask could not be processed'}, 500: 'The feedback of this subtask could not be processed'},
operation_description="Generate feedback_doc of subtask output dataproducts from the subtask raw_feedback and set subtask state to finished.") operation_description="Store the archive information for this dataproduct.")
@action(methods=['post'], detail=True, url_name='process_archive_information') @action(methods=['post'], detail=True, url_name='post_archive_information')
def process_archive_information(self, request, pk=None): def post_archive_information(self, request, pk=None):
dataproduct = get_object_or_404(models.Dataproduct, pk=pk) dataproduct = get_object_or_404(models.Dataproduct, pk=pk)
if dataproduct.producer.subtask.specifications_template.type.value != models.SubtaskType.Choices.INGEST.value:
raise TMSSException("Cannot store archive information for dataproduct id=%s because its producing subtask id=%s is of non-ingest type=%s" % (pk, dataproduct.producer.subtask.id,
dataproduct.producer.subtask.specifications_template.type.value))
json_doc = json.loads(request.body.decode('utf-8')) json_doc = json.loads(request.body.decode('utf-8'))
dataproduct.size = int(json_doc['file_size']) dataproduct.size = int(json_doc['file_size'])
...@@ -385,6 +390,10 @@ class DataproductViewSet(LOFARViewSet): ...@@ -385,6 +390,10 @@ class DataproductViewSet(LOFARViewSet):
algorithm=models.Algorithm.objects.get(value=models.Algorithm.Choices.ADLER32.value), algorithm=models.Algorithm.objects.get(value=models.Algorithm.Choices.ADLER32.value),
hash=json_doc['adler32_checksum']) hash=json_doc['adler32_checksum'])
# create empty feedback. Apart from the archive info above, ingest does not create feedback like observations/pipelines do.
dataproduct.feedback_template = models.DataproductFeedbackTemplate.objects.get(name="empty")
dataproduct.feedback_doc = get_default_json_object_for_schema(dataproduct.feedback_template.schema)
dataproduct.save() dataproduct.save()
serializer = self.get_serializer(dataproduct) serializer = self.get_serializer(dataproduct)
return RestResponse(serializer.data) return RestResponse(serializer.data)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment