Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Remove async/await (#150)
Browse files Browse the repository at this point in the history
Also removed duplicated code from templates for creating additional endpoint with shorter semver
  • Loading branch information
kravetsmic authored Mar 28, 2023
1 parent 823d620 commit 060ead4
Show file tree
Hide file tree
Showing 18 changed files with 50 additions and 248 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 0.8.1

* Removed async/await from endpoints.
* Refactored template for generating endpoints with shorter semver.

# 0.8.0

* Add duplicate routes with semver major version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@


@app.get("/healthcheck", status_code=status.HTTP_200_OK)
async def healthcheck(request: Request):
def healthcheck(request: Request):
return {"healthcheck": "HEALTHCHECK STATUS: EVERYTHING OK!"}
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ async def stream_response(self, send: Send) -> None:
await send({"type": "http.response.body", "body": b"", "more_body": False})


@router.post("/test-project/v1/process-file-1")
@router.post("/test-project/v1.2.3/process-file-1")
async def pipeline_1(
def pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
input2: List[str] = Form(default=[]),
Expand Down Expand Up @@ -195,21 +196,8 @@ def response_generator(is_multipart):
)


@router.post("/test-project/v1/process-file-1")
async def short_pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
input2: List[str] = Form(default=[]),
):
return await pipeline_1(
request=request,
files=files,
input2=input2,
)


@app.get("/healthcheck", status_code=status.HTTP_200_OK)
async def healthcheck(request: Request):
def healthcheck(request: Request):
return {"healthcheck": "HEALTHCHECK STATUS: EVERYTHING OK!"}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ async def stream_response(self, send: Send) -> None:
await send({"type": "http.response.body", "body": b"", "more_body": False})


@router.post("/test-project/v1/process-file-2")
@router.post("/test-project/v1.2.3/process-file-2")
async def pipeline_1(
def pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
):
Expand Down Expand Up @@ -179,19 +180,8 @@ def response_generator(is_multipart):
)


@router.post("/test-project/v1/process-file-2")
async def short_pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
):
return await pipeline_1(
request=request,
files=files,
)


@app.get("/healthcheck", status_code=status.HTTP_200_OK)
async def healthcheck(request: Request):
def healthcheck(request: Request):
return {"healthcheck": "HEALTHCHECK STATUS: EVERYTHING OK!"}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ async def stream_response(self, send: Send) -> None:
await send({"type": "http.response.body", "body": b"", "more_body": False})


@router.post("/test-project/v1/process-file-3")
@router.post("/test-project/v1.2.3/process-file-3")
async def pipeline_1(
def pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
output_format: Union[str, None] = Form(default=None),
Expand Down Expand Up @@ -221,23 +222,8 @@ def response_generator(is_multipart):
)


@router.post("/test-project/v1/process-file-3")
async def short_pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
output_format: Union[str, None] = Form(default=None),
output_schema: str = Form(default=None),
):
return await pipeline_1(
request=request,
files=files,
output_format=output_format,
output_schema=output_schema,
)


@app.get("/healthcheck", status_code=status.HTTP_200_OK)
async def healthcheck(request: Request):
def healthcheck(request: Request):
return {"healthcheck": "HEALTHCHECK STATUS: EVERYTHING OK!"}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,9 @@ async def stream_response(self, send: Send) -> None:
await send({"type": "http.response.body", "body": b"", "more_body": False})


@router.post("/test-project/v1/process-file-4")
@router.post("/test-project/v1.2.3/process-file-4")
async def pipeline_1(
def pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
output_format: Union[str, None] = Form(default=None),
Expand Down Expand Up @@ -238,25 +239,8 @@ def response_generator(is_multipart):
)


@router.post("/test-project/v1/process-file-4")
async def short_pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
output_format: Union[str, None] = Form(default=None),
output_schema: str = Form(default=None),
input1: List[str] = Form(default=[]),
):
return await pipeline_1(
request=request,
files=files,
output_format=output_format,
output_schema=output_schema,
input1=input1,
)


@app.get("/healthcheck", status_code=status.HTTP_200_OK)
async def healthcheck(request: Request):
def healthcheck(request: Request):
return {"healthcheck": "HEALTHCHECK STATUS: EVERYTHING OK!"}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ async def stream_response(self, send: Send) -> None:
await send({"type": "http.response.body", "body": b"", "more_body": False})


@router.post("/test-project/v1/process-file-5")
@router.post("/test-project/v1.2.3/process-file-5")
async def pipeline_1(
def pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
output_format: Union[str, None] = Form(default=None),
Expand Down Expand Up @@ -243,27 +244,8 @@ def response_generator(is_multipart):
)


@router.post("/test-project/v1/process-file-5")
async def short_pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
output_format: Union[str, None] = Form(default=None),
output_schema: str = Form(default=None),
input1: List[str] = Form(default=[]),
input2: List[str] = Form(default=[]),
):
return await pipeline_1(
request=request,
files=files,
output_format=output_format,
output_schema=output_schema,
input1=input1,
input2=input2,
)


@app.get("/healthcheck", status_code=status.HTTP_200_OK)
async def healthcheck(request: Request):
def healthcheck(request: Request):
return {"healthcheck": "HEALTHCHECK STATUS: EVERYTHING OK!"}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ async def stream_response(self, send: Send) -> None:
await send({"type": "http.response.body", "body": b"", "more_body": False})


@router.post("/test-project/v1/process-text-1")
@router.post("/test-project/v1.2.3/process-text-1")
async def pipeline_1(
def pipeline_1(
request: Request,
text_files: Union[List[UploadFile], None] = File(default=None),
):
Expand Down Expand Up @@ -178,19 +179,8 @@ def response_generator(is_multipart):
)


@router.post("/test-project/v1/process-text-1")
async def short_pipeline_1(
request: Request,
text_files: Union[List[UploadFile], None] = File(default=None),
):
return await pipeline_1(
request=request,
text_files=text_files,
)


@app.get("/healthcheck", status_code=status.HTTP_200_OK)
async def healthcheck(request: Request):
def healthcheck(request: Request):
return {"healthcheck": "HEALTHCHECK STATUS: EVERYTHING OK!"}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ async def stream_response(self, send: Send) -> None:
await send({"type": "http.response.body", "body": b"", "more_body": False})


@router.post("/test-project/v1/process-text-2")
@router.post("/test-project/v1.2.3/process-text-2")
async def pipeline_1(
def pipeline_1(
request: Request,
text_files: Union[List[UploadFile], None] = File(default=None),
input1: List[str] = Form(default=[]),
Expand Down Expand Up @@ -185,23 +186,8 @@ def response_generator(is_multipart):
)


@router.post("/test-project/v1/process-text-2")
async def short_pipeline_1(
request: Request,
text_files: Union[List[UploadFile], None] = File(default=None),
input1: List[str] = Form(default=[]),
input2: List[str] = Form(default=[]),
):
return await pipeline_1(
request=request,
text_files=text_files,
input1=input1,
input2=input2,
)


@app.get("/healthcheck", status_code=status.HTTP_200_OK)
async def healthcheck(request: Request):
def healthcheck(request: Request):
return {"healthcheck": "HEALTHCHECK STATUS: EVERYTHING OK!"}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ async def stream_response(self, send: Send) -> None:
await send({"type": "http.response.body", "body": b"", "more_body": False})


@router.post("/test-project/v1/process-text-3")
@router.post("/test-project/v1.2.3/process-text-3")
async def pipeline_1(
def pipeline_1(
request: Request,
text_files: Union[List[UploadFile], None] = File(default=None),
output_format: Union[str, None] = Form(default=None),
Expand Down Expand Up @@ -210,21 +211,8 @@ def response_generator(is_multipart):
)


@router.post("/test-project/v1/process-text-3")
async def short_pipeline_1(
request: Request,
text_files: Union[List[UploadFile], None] = File(default=None),
output_format: Union[str, None] = Form(default=None),
):
return await pipeline_1(
request=request,
text_files=text_files,
output_format=output_format,
)


@app.get("/healthcheck", status_code=status.HTTP_200_OK)
async def healthcheck(request: Request):
def healthcheck(request: Request):
return {"healthcheck": "HEALTHCHECK STATUS: EVERYTHING OK!"}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ async def stream_response(self, send: Send) -> None:
await send({"type": "http.response.body", "body": b"", "more_body": False})


@router.post("/test-project/v1/process-text-4")
@router.post("/test-project/v1.2.3/process-text-4")
async def pipeline_1(
def pipeline_1(
request: Request,
text_files: Union[List[UploadFile], None] = File(default=None),
output_format: Union[str, None] = Form(default=None),
Expand Down Expand Up @@ -223,23 +224,8 @@ def response_generator(is_multipart):
)


@router.post("/test-project/v1/process-text-4")
async def short_pipeline_1(
request: Request,
text_files: Union[List[UploadFile], None] = File(default=None),
output_format: Union[str, None] = Form(default=None),
output_schema: str = Form(default=None),
):
return await pipeline_1(
request=request,
text_files=text_files,
output_format=output_format,
output_schema=output_schema,
)


@app.get("/healthcheck", status_code=status.HTTP_200_OK)
async def healthcheck(request: Request):
def healthcheck(request: Request):
return {"healthcheck": "HEALTHCHECK STATUS: EVERYTHING OK!"}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,9 @@ async def stream_response(self, send: Send) -> None:
await send({"type": "http.response.body", "body": b"", "more_body": False})


@router.post("/test-project/v1/process-text-file-1")
@router.post("/test-project/v1.2.3/process-text-file-1")
async def pipeline_1(
def pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
text_files: Union[List[UploadFile], None] = File(default=None),
Expand Down Expand Up @@ -224,21 +225,8 @@ def response_generator(is_multipart):
return response


@router.post("/test-project/v1/process-text-file-1")
async def short_pipeline_1(
request: Request,
files: Union[List[UploadFile], None] = File(default=None),
text_files: Union[List[UploadFile], None] = File(default=None),
):
return await pipeline_1(
request=request,
files=files,
text_files=text_files,
)


@app.get("/healthcheck", status_code=status.HTTP_200_OK)
async def healthcheck(request: Request):
def healthcheck(request: Request):
return {"healthcheck": "HEALTHCHECK STATUS: EVERYTHING OK!"}


Expand Down
Loading

0 comments on commit 060ead4

Please sign in to comment.