Example #1
0
 def get(self, request, pk):
     try:
         run = Run.objects.get(id=pk)
     except Run.DoesNotExist:
         return Response({'details': 'Run %s not found' % str(pk)},
                         status=status.HTTP_404_NOT_FOUND)
     try:
         resolved_dict = get_pipeline(run.app)
     except Exception as e:
         return Response({'details': str(e)},
                         status=status.HTTP_400_BAD_REQUEST)
     app = "data:text/plain;base64,%s" % base64.b64encode(
         json.dumps(resolved_dict).encode("utf-8")).decode('utf-8')
     run_serializer = RunSerializerFull(run)
     inputs = {}
     for inp in run_serializer.data['inputs']:
         if inp['value']:
             inputs[inp['name']] = inp['value'].get('inputs')
     data = {"app": app, "inputs": inputs, "config": {}}
     r = requests.post(url=settings.RABIX_URL + "/v0/engine/jobs/",
                       headers={"content-type": "application/json"},
                       data=json.dumps(data))
     if r.status_code != 200:
         return Response(r.json(), status=r.status_code)
     data = r.json()
     execution_id = data['rootId']
     run.execution_id = uuid.UUID(execution_id)
     run.status = RunStatus.RUNNING
     run.save()
     response = RunSerializerFull(run)
     return Response(response.data, status=status.HTTP_200_OK)
Example #2
0
 def get(self, request, pk):
     try:
         pipeline = Pipeline.objects.get(id=pk)
     except Pipeline.DoesNotExist:
         return Response({}, status=status.HTTP_404_NOT_FOUND)
     try:
         resolved_dict = get_pipeline(pipeline)
     except Exception as e:
         return Response({'details': str(e)},
                         status=status.HTTP_400_BAD_REQUEST)
     serializer = PipelineResolvedSerializer(data={'app': resolved_dict})
     if serializer.is_valid():
         return Response(serializer.data, status=status.HTTP_200_OK)
     return Response({}, status=status.HTTP_404_NOT_FOUND)
Example #3
0
 def get(self, request, pk):
     try:
         pipeline = Pipeline.objects.get(id=pk)
     except Pipeline.DoesNotExist:
         return Response({}, status=status.HTTP_404_NOT_FOUND)
     try:
         resolved_dict = get_pipeline(pipeline)
     except Exception as e:
         return Response({'details': str(e)},
                         status=status.HTTP_400_BAD_REQUEST)
     response = HttpResponse(json.dumps(resolved_dict),
                             content_type='text/plain; charset=UTF-8')
     response['Content-Disposition'] = (
         'attachment; filename={0}'.format('aplication.cwl'))
     return response