Skip to content

Commit

Permalink
Merge branch 'main' into feat/increate-request-timeout-for-upload
Browse files Browse the repository at this point in the history
  • Loading branch information
paaragon committed Oct 16, 2024
2 parents 9c4db0d + b1050b4 commit f5dc475
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 61 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/update-component-versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
sed -i "s/ray-node:${OLDNUM}/ray-node:${NEWNUM}/" charts/qiskit-serverless/values.yaml
sed -i "s/version: ${OLDNUM}/version: ${NEWNUM}/" charts/qiskit-serverless/values.yaml
sed -i "s/qiskit-serverless\/ray-node:${OLDNUM}/qiskit-serverless\/ray-node:${NEWNUM}/" docs/deployment/custom_function/Sample-Dockerfile
sed -i "s/FROM icr.io\/quantum-public\/qiskit-serverless\/ray-node${OLDNUM}/FROM icr.io\/quantum-public\/qiskit-serverless\/ray-node${NEWNUM}/" docs/deployment/deploying_custom_image_function.rst
sed -i "s/FROM icr.io\/quantum-public\/qiskit-serverless\/ray-node${OLDNUM}/FROM icr.io\/quantum-public\/qiskit-serverless\/ray-node${NEWNUM}/" docs/deployment/example_custom_image_function.rst
sed -i "s/qiskit-serverless\/ray-node:${OLDNUM}/qiskit-serverless\/ray-node:${NEWNUM}/" gateway/main/settings.py
cd charts/qiskit-serverless
helm dependency update
Expand Down
77 changes: 77 additions & 0 deletions gateway/api/v1/views/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
Files view api for V1.
"""

from drf_yasg import openapi
from drf_yasg.utils import swagger_auto_schema
from rest_framework import permissions
from rest_framework.decorators import action

from api.permissions import IsOwner
from api import views
Expand All @@ -14,3 +17,77 @@ class FilesViewSet(views.FilesViewSet):
"""

permission_classes = [permissions.IsAuthenticated, IsOwner]

@swagger_auto_schema(
operation_description="List of available for user files",
manual_parameters=[
openapi.Parameter(
"provider",
openapi.IN_QUERY,
description="provider name",
type=openapi.TYPE_STRING,
required=False,
),
],
)
def list(self, request):
return super().list(request)

@swagger_auto_schema(
operation_description="Download a specific file",
manual_parameters=[
openapi.Parameter(
"file",
openapi.IN_QUERY,
description="file name",
type=openapi.TYPE_STRING,
required=True,
),
openapi.Parameter(
"provider",
openapi.IN_QUERY,
description="provider name",
type=openapi.TYPE_STRING,
required=False,
),
],
)
@action(methods=["GET"], detail=False)
def download(self, request):
return super().download(request)

@swagger_auto_schema(
operation_description="Deletes file uploaded or produced by the programs",
request_body=openapi.Schema(
type=openapi.TYPE_OBJECT,
properties={
"file": openapi.Schema(
type=openapi.TYPE_STRING, description="file name"
),
"provider": openapi.Schema(
type=openapi.TYPE_STRING, description="provider name"
),
},
required=["file"],
),
)
@action(methods=["DELETE"], detail=False)
def delete(self, request):
return super().delete(request)

@swagger_auto_schema(
operation_description="Upload selected file",
request_body=openapi.Schema(
type=openapi.TYPE_OBJECT,
properties={
"file": openapi.Schema(type=openapi.TYPE_FILE, description="file name"),
"provider": openapi.Schema(
type=openapi.TYPE_STRING, description="provider name"
),
},
required=["file"],
),
)
@action(methods=["POST"], detail=False)
def upload(self, request):
return super().upload(request)
61 changes: 0 additions & 61 deletions gateway/api/views/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import os
from wsgiref.util import FileWrapper

from drf_yasg import openapi
from drf_yasg.utils import swagger_auto_schema
from django.conf import settings
from django.http import StreamingHttpResponse

Expand Down Expand Up @@ -69,18 +67,6 @@ def check_user_has_provider(self, user, provider_name):
"""check if user has the provider"""
return provider_name in self.list_user_providers(user)

@swagger_auto_schema(
operation_description="List of available for user files",
manual_parameters=[
openapi.Parameter(
"provider",
openapi.IN_QUERY,
description="provider name",
type=openapi.TYPE_STRING,
required=False,
),
],
)
def list(self, request):
"""List of available for user files."""
response = Response(
Expand Down Expand Up @@ -115,25 +101,6 @@ def list(self, request):

return Response({"results": files})

@swagger_auto_schema(
operation_description="List of available for user files",
manual_parameters=[
openapi.Parameter(
"file",
openapi.IN_QUERY,
description="file name",
type=openapi.TYPE_STRING,
required=True,
),
openapi.Parameter(
"provider",
openapi.IN_QUERY,
description="provider name",
type=openapi.TYPE_STRING,
required=False,
),
],
)
@action(methods=["GET"], detail=False)
def download(self, request): # pylint: disable=invalid-name
"""Download selected file."""
Expand Down Expand Up @@ -179,21 +146,6 @@ def download(self, request): # pylint: disable=invalid-name
response["Content-Disposition"] = f"attachment; filename={filename}"
return response

@swagger_auto_schema(
operation_description="Deletes file uploaded or produced by the programs",
request_body=openapi.Schema(
type=openapi.TYPE_OBJECT,
properties={
"file": openapi.Schema(
type=openapi.TYPE_STRING, description="file name"
),
"provider": openapi.Schema(
type=openapi.TYPE_STRING, description="provider name"
),
},
required=["file"],
),
)
@action(methods=["DELETE"], detail=False)
def delete(self, request): # pylint: disable=invalid-name
"""Deletes file uploaded or produced by the programs,"""
Expand Down Expand Up @@ -230,19 +182,6 @@ def delete(self, request): # pylint: disable=invalid-name
)
return response

@swagger_auto_schema(
operation_description="Upload selected file",
request_body=openapi.Schema(
type=openapi.TYPE_OBJECT,
properties={
"file": openapi.Schema(type=openapi.TYPE_FILE, description="file name"),
"provider": openapi.Schema(
type=openapi.TYPE_STRING, description="provider name"
),
},
required=["file"],
),
)
@action(methods=["POST"], detail=False)
def upload(self, request): # pylint: disable=invalid-name
"""Upload selected file."""
Expand Down

0 comments on commit f5dc475

Please sign in to comment.