Skip to content

Commit

Permalink
feat(podorc): add po eps and refactor k8s to podorc build_image
Browse files Browse the repository at this point in the history
  • Loading branch information
brucetony committed Mar 22, 2024
1 parent 37fa44e commit 3279e73
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 57 deletions.
4 changes: 4 additions & 0 deletions gateway/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def route(
form_params: list[str] | None = None,
body_params: list[str] | None = None,
response_model: any = None, # TODO: Make specific for pydantic models
response_class: any = None, # TODO: Make specific for pydantic response classes
tags: list[str] = None,
dependencies: Sequence[params.Depends] | None = None,
summary: str | None = None,
Expand Down Expand Up @@ -113,6 +114,8 @@ def route(
Keys passed referencing body data parameters to be sent to downstream microservice
response_model
Response model of the forwarded request. Can be imported from other packages.
response_class
Response class of the forwarded request. Can be imported from other packages.
tags : list[str]
List of tags used to classify methods
dependencies: Sequence[params.Depends] | None
Expand All @@ -135,6 +138,7 @@ def route(
path,
status_code=status_code,
response_model=response_model,
response_class=response_class,
tags=tags,
dependencies=dependencies,
summary=summary,
Expand Down
55 changes: 0 additions & 55 deletions gateway/routers/k8s.py

This file was deleted.

116 changes: 116 additions & 0 deletions gateway/routers/podorc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
"""EPs for the pod orchestrator."""
import logging
from typing import Annotated

from fastapi import APIRouter, Path, Security
from fastapi.responses import JSONResponse
from starlette import status
from starlette.requests import Request
from starlette.responses import Response

from gateway.auth import verify_idp_token, idp_oauth2_scheme_pass
from gateway.conf import gateway_settings
from gateway.core import route

po_router = APIRouter(
dependencies=[Security(verify_idp_token), Security(idp_oauth2_scheme_pass)],
tags=["PodOrc"],
responses={404: {"description": "Not found"}},
)
logger = logging.getLogger(__name__)


@route(
request_method=po_router.post,
path="/{analysis_id}",
status_code=status.HTTP_200_OK,
service_url=gateway_settings.PODORC_SERVICE_URL,
response_class=JSONResponse,
)
async def create_analysis(
request: Request,
response: Response,
analysis_id: Annotated[str | None, Path(description="UUID of the analysis.")],
):
"""Get the logs for a specific analysis run."""
pass


@route(
request_method=po_router.get,
path="/{analysis_id}/logs",
status_code=status.HTTP_200_OK,
service_url=gateway_settings.PODORC_SERVICE_URL,
response_class=JSONResponse,
)
async def get_analysis_logs(
request: Request,
response: Response,
analysis_id: Annotated[str | None, Path(description="UUID of the analysis.")],
):
"""Get the logs for a specific analysis run."""
pass


@route(
request_method=po_router.get,
path="/{analysis_id}/status",
status_code=status.HTTP_200_OK,
service_url=gateway_settings.PODORC_SERVICE_URL,
response_class=JSONResponse,
)
async def get_analysis_status(
request: Request,
response: Response,
analysis_id: Annotated[str | None, Path(description="UUID of the analysis.")],
):
"""Get the status for a specific analysis run."""
pass


@route(
request_method=po_router.get,
path="/{analysis_id}/pods",
status_code=status.HTTP_200_OK,
service_url=gateway_settings.PODORC_SERVICE_URL,
response_class=JSONResponse,
)
async def get_analysis_pods(
request: Request,
response: Response,
analysis_id: Annotated[str | None, Path(description="UUID of the analysis.")],
):
"""Get the pods for a specific analysis run."""
pass


@route(
request_method=po_router.put,
path="/{analysis_id}/stop",
status_code=status.HTTP_200_OK,
service_url=gateway_settings.PODORC_SERVICE_URL,
response_class=JSONResponse,
)
async def stop_analysis(
request: Request,
response: Response,
analysis_id: Annotated[str | None, Path(description="UUID of the analysis.")],
):
"""Stop a specific analysis run."""
pass


@route(
request_method=po_router.delete,
path="/{analysis_id}/delete",
status_code=status.HTTP_200_OK,
service_url=gateway_settings.PODORC_SERVICE_URL,
response_class=JSONResponse,
)
async def delete_analysis(
request: Request,
response: Response,
analysis_id: Annotated[str | None, Path(description="UUID of the analysis.")],
):
"""Delete a specific analysis run."""
pass
4 changes: 2 additions & 2 deletions gateway/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
from gateway.models import HealthCheck
from gateway.models.conf import Token
from gateway.routers.hub import hub_router
from gateway.routers.k8s import k8s_router
from gateway.routers.kong import kong_router
from gateway.routers.metadata import metadata_router
from gateway.routers.podorc import po_router
from gateway.routers.results import results_router


Expand Down Expand Up @@ -118,7 +118,7 @@ def get_token(form_data: Annotated[OAuth2PasswordRequestForm, Depends()]) -> Tok


app.include_router(
k8s_router,
po_router,
)

app.include_router(
Expand Down

0 comments on commit 3279e73

Please sign in to comment.