diff --git a/datalab/datalab_session/viewsets.py b/datalab/datalab_session/viewsets.py index d31bb76..0af76da 100644 --- a/datalab/datalab_session/viewsets.py +++ b/datalab/datalab_session/viewsets.py @@ -1,4 +1,5 @@ from rest_framework import viewsets +from rest_framework.response import Response from django_filters.rest_framework import DjangoFilterBackend from datalab.datalab_session.serializers import DataSessionSerializer, DataOperationSerializer @@ -18,6 +19,15 @@ def perform_create(self, serializer): serializer.save(session_id=self.kwargs['session_pk'], cache_key=operation.cache_key) operation.perform_operation() + def retrieve(self, request, *args, **kwargs): + instance = self.get_object() + serializer = self.get_serializer(instance) + if instance.status == 'PENDING' and not instance.output: + operation = available_operations().get(instance.name)(instance.input_data) + operation.perform_operation() + + return Response(serializer.data) + class DataSessionViewSet(viewsets.ModelViewSet): serializer_class = DataSessionSerializer