From ea545001588644de4cfde2de03e234af45e41b78 Mon Sep 17 00:00:00 2001 From: Joan Martinez Date: Tue, 17 Dec 2024 18:18:54 +0100 Subject: [PATCH] feat: change return error code --- .github/workflows/cd.yml | 3 --- .github/workflows/ci.yml | 5 +---- jina/serve/runtimes/gateway/http_fastapi_app_docarrayv2.py | 4 ++-- jina/serve/runtimes/worker/http_csp_app.py | 4 ++-- jina/serve/runtimes/worker/http_fastapi_app.py | 4 ++-- jina/serve/runtimes/worker/request_handling.py | 3 +-- 6 files changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 805582199bfb3..f007fd64efc99 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -281,9 +281,6 @@ jobs: matrix: include: # linux - - os: ubuntu-latest - python: '3.7' - python-manylinux-tag: "cp37-cp37m" - os: ubuntu-latest python: '3.8' python-manylinux-tag: "cp38-cp38" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be1a07813463d..f694296bfa68a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,7 +42,7 @@ jobs: with: fetch-depth: 0 - name: Set up Python 3.8 - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: 3.8 - id: file_changes @@ -584,9 +584,6 @@ jobs: matrix: include: # linux - - os: ubuntu-latest - python: '3.7' - python-manylinux-tag: "cp37-cp37m" - os: ubuntu-latest python: '3.8' python-manylinux-tag: "cp38-cp38" diff --git a/jina/serve/runtimes/gateway/http_fastapi_app_docarrayv2.py b/jina/serve/runtimes/gateway/http_fastapi_app_docarrayv2.py index 76e3c429da7b9..9939ced58acf0 100644 --- a/jina/serve/runtimes/gateway/http_fastapi_app_docarrayv2.py +++ b/jina/serve/runtimes/gateway/http_fastapi_app_docarrayv2.py @@ -41,7 +41,7 @@ def get_fastapi_app( if expose_graphql_endpoint: logger.error(f' GraphQL endpoint is not enabled when using docarray >0.30') with ImportExtensions(required=True): - from fastapi import FastAPI, Response, HTTPException + from fastapi import FastAPI, Response, HTTPException, status as http_status from fastapi.middleware.cors import CORSMiddleware import pydantic from pydantic import Field @@ -216,7 +216,7 @@ async def post(body: input_model, response: Response): status = resp.header.status if status.code == jina_pb2.StatusProto.ERROR: - raise HTTPException(status_code=499, detail=status.description) + raise HTTPException(status_code=http_status.HTTP_500_INTERNAL_SERVER_ERROR, detail=status.description) else: result_dict = resp.to_dict() return result_dict diff --git a/jina/serve/runtimes/worker/http_csp_app.py b/jina/serve/runtimes/worker/http_csp_app.py index a670a0d1d932c..442241f416f07 100644 --- a/jina/serve/runtimes/worker/http_csp_app.py +++ b/jina/serve/runtimes/worker/http_csp_app.py @@ -30,7 +30,7 @@ def get_fastapi_app( """ with ImportExtensions(required=True): import pydantic - from fastapi import FastAPI, HTTPException, Request + from fastapi import FastAPI, HTTPException, Request, status as http_status from fastapi.middleware.cors import CORSMiddleware from pydantic import BaseModel, Field from pydantic.config import BaseConfig, inherit_config @@ -131,7 +131,7 @@ async def process(body) -> output_model: status = resp.header.status if status.code == jina_pb2.StatusProto.ERROR: - raise HTTPException(status_code=499, detail=status.description) + raise HTTPException(status_code=http_status.HTTP_500_INTERNAL_SERVER_ERROR, detail=status.description) else: return output_model(data=resp.docs, parameters=resp.parameters) diff --git a/jina/serve/runtimes/worker/http_fastapi_app.py b/jina/serve/runtimes/worker/http_fastapi_app.py index 889166d8aeb63..edb4c9dba7afa 100644 --- a/jina/serve/runtimes/worker/http_fastapi_app.py +++ b/jina/serve/runtimes/worker/http_fastapi_app.py @@ -33,7 +33,7 @@ def get_fastapi_app( :return: fastapi app """ with ImportExtensions(required=True): - from fastapi import FastAPI, Response, HTTPException + from fastapi import FastAPI, Response, HTTPException, status as http_status import pydantic from fastapi.middleware.cors import CORSMiddleware import os @@ -116,7 +116,7 @@ async def post(body: input_model, response: Response): status = resp.header.status if status.code == jina_pb2.StatusProto.ERROR: - raise HTTPException(status_code=499, detail=status.description) + raise HTTPException(status_code=http_status.HTTP_500_INTERNAL_SERVER_ERROR, detail=status.description) else: if not docarray_v2: docs_response = resp.docs.to_dict() diff --git a/jina/serve/runtimes/worker/request_handling.py b/jina/serve/runtimes/worker/request_handling.py index 450690d33bcdc..97d90fa954372 100644 --- a/jina/serve/runtimes/worker/request_handling.py +++ b/jina/serve/runtimes/worker/request_handling.py @@ -1079,7 +1079,6 @@ def _extract_tracing_context( ) -> Optional['Context']: if self.tracer: from opentelemetry.propagate import extract - context = extract(dict(metadata)) return context @@ -1116,7 +1115,7 @@ async def process_data( if is_generator: result = await self.handle_generator( - requests=requests,tracing_context=tracing_context + requests=requests, tracing_context=tracing_context ) else: result = await self.handle(