Skip to content

Commit

Permalink
@GitHK review: constants
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Jul 21, 2023
1 parent 7550a6a commit 7b8dea6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import io
import logging
from textwrap import dedent
from typing import IO, Annotated
from typing import IO, Annotated, Final
from uuid import UUID

from fastapi import APIRouter, Depends
Expand Down Expand Up @@ -42,7 +42,7 @@
#
#

_common_error_responses = {
_COMMON_ERROR_RESPONSES: Final[dict] = {
status.HTTP_404_NOT_FOUND: {
"description": "File not found",
"model": ErrorGet,
Expand Down Expand Up @@ -170,7 +170,7 @@ async def upload_files(files: list[UploadFile] = FileParam(...)):
raise NotImplementedError


@router.get("/{file_id}", response_model=File, responses={**_common_error_responses})
@router.get("/{file_id}", response_model=File, responses={**_COMMON_ERROR_RESPONSES})
async def get_file(
file_id: UUID,
storage_client: Annotated[StorageApi, Depends(get_api_client(StorageApi))],
Expand Down Expand Up @@ -203,7 +203,7 @@ async def get_file(
@router.delete(
"/{file_id}",
status_code=status.HTTP_204_NO_CONTENT,
responses={**_common_error_responses},
responses={**_COMMON_ERROR_RESPONSES},
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
)
async def delete_file(
Expand All @@ -221,7 +221,7 @@ async def delete_file(
"/{file_id}/content",
response_class=RedirectResponse,
responses={
**_common_error_responses,
**_COMMON_ERROR_RESPONSES,
200: {
"content": {
"application/octet-stream": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import logging
from collections import deque
from collections.abc import Callable
from typing import Annotated
from typing import Annotated, Final
from uuid import UUID

from fastapi import APIRouter, Depends, status
Expand Down Expand Up @@ -65,7 +65,7 @@ def _compose_job_resource_name(solver_key, solver_version, job_id) -> str:
# - Similar to docker container's API design (container = job and image = solver)
#

_common_error_responses = {
_COMMON_ERROR_RESPONSES: Final[dict] = {
status.HTTP_404_NOT_FOUND: {
"description": "Job not found",
"model": ErrorGet,
Expand Down Expand Up @@ -443,7 +443,7 @@ async def get_job_output_logfile(
@router.get(
"/{solver_key:path}/releases/{version}/jobs/{job_id:uuid}/metadata",
response_model=JobMetadata,
responses={**_common_error_responses},
responses={**_COMMON_ERROR_RESPONSES},
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
)
async def get_job_custom_metadata(
Expand Down Expand Up @@ -484,7 +484,7 @@ async def get_job_custom_metadata(
@router.patch(
"/{solver_key:path}/releases/{version}/jobs/{job_id:uuid}/metadata",
response_model=JobMetadata,
responses={**_common_error_responses},
responses={**_COMMON_ERROR_RESPONSES},
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
)
async def replace_job_custom_metadata(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Annotated, Any
from typing import Annotated, Any, Final

from fastapi import APIRouter, Depends, status
from fastapi_pagination.api import create_page
Expand All @@ -16,7 +16,7 @@
_logger = logging.getLogger(__name__)
router = APIRouter()

_common_error_responses = {
_COMMON_ERROR_RESPONSES: Final[dict] = {
status.HTTP_404_NOT_FOUND: {
"description": "Study not found",
"model": ErrorGet,
Expand Down Expand Up @@ -65,7 +65,7 @@ async def list_studies(
@router.get(
"/{study_id}",
response_model=Study,
responses={**_common_error_responses},
responses={**_COMMON_ERROR_RESPONSES},
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
)
async def get_study(
Expand All @@ -90,7 +90,7 @@ async def get_study(
@router.get(
"/{study_id}/ports",
response_model=OnePage[StudyPort],
responses={**_common_error_responses},
responses={**_COMMON_ERROR_RESPONSES},
include_in_schema=API_SERVER_DEV_FEATURES_ENABLED,
)
async def list_study_ports(
Expand Down

0 comments on commit 7b8dea6

Please sign in to comment.