Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reload an operation when it no longer exists in the cache #34

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions datalab/datalab_session/viewsets.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if an operation is retried but its inputs don't exist yet (because they're also being recreated). Would have to wait or know somehow when the input_data is ready

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I guess in our current system it would "Fail" if the inputs didn't exist at that moment and then be removed from the UI so that isn't great. I was trying to avoid making the getting operation logic more complicated to the point where it checks previous operations being done before attempting, but maybe that is the way to go.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this kinda ties in to the original plan of having recipes that are saved, thats a whole 'nother can of worms

operation.perform_operation()

return Response(serializer.data)


class DataSessionViewSet(viewsets.ModelViewSet):
serializer_class = DataSessionSerializer
Expand Down
Loading