Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#4 convert fastapi #5

Merged
merged 3 commits into from
Aug 8, 2020
Merged

Feature/#4 convert fastapi #5

merged 3 commits into from
Aug 8, 2020

Conversation

ssaru
Copy link
Member

@ssaru ssaru commented Aug 6, 2020

Pull Request

레파지토리에 기여해주셔서 감사드립니다.

해당 PR을 제출하기 전에 아래 사항이 완료되었는지 확인 부탁드립니다:

  • 작성한 코드가 어떤 에러나 경고없이 빌드가 되었나요?
  • 충분한 테스트를 수행하셨나요?

1. 해당 PR은 어떤 내용인가요?

  • Flask Serving을 FastAPI로 변경

2. PR과 관련된 이슈가 있나요?

#4

@ssaru ssaru added the enhancement New feature or request label Aug 6, 2020
@ssaru ssaru requested review from dreamgonfly, soeque1 and seopbo August 6, 2020 19:03
@ssaru ssaru self-assigned this Aug 6, 2020
@ssaru ssaru requested a review from gogyzzz August 8, 2020 04:47
@ssaru
Copy link
Member Author

ssaru commented Aug 8, 2020

@gogyzzz PR 리뷰어 설정했습니다.

@ssaru ssaru requested review from hyerim1048 and Taekyoon August 8, 2020 07:23
describtion="MNIST 모델을 추론하는 API입니다")
namespace = api.namespace('mnist', description='MNIST 모델')
from fastapi import FastAPI
from handler import (Handler, Request, Response)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Response는 정의해놓고 안쓰이는 것 같은데 맞나요??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ app.post("/model/")
async def inference(request: Request):
    response = handler(request)
    return response

에서 response는 Response 객체입니다.

Response 객체는 아래와 같구요.

class Response(BaseModel):
    prediction: str

이 Response 객체는 Handler의 던더메소드인 __call__에서 오구요.

def __call__(self, request: Request) -> str:
       base64image: str = request.base64_image_string
        inputs: torch.Tensor = self._preprocessing(base64image)
        prediction: str = self.model.inference(inputs)

        return Response(prediction=prediction)

최종적으로 return된 Response객체는 브라우져에서 아래와 같이 보이게됩니다.

{
    "prediction" : (str)
}

@codecov
Copy link

codecov bot commented Aug 8, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@1008076). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master       #5   +/-   ##
=========================================
  Coverage          ?   31.32%           
=========================================
  Files             ?        7           
  Lines             ?       83           
  Branches          ?        0           
=========================================
  Hits              ?       26           
  Misses            ?       57           
  Partials          ?        0           
Flag Coverage Δ
#tests 31.32% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1008076...5635270. Read the comment docs.

@dreamgonfly dreamgonfly self-requested a review August 8, 2020 08:32
@ssaru ssaru merged commit 9e5fb67 into master Aug 8, 2020
@ssaru ssaru deleted the feature/#4-convert-fastapi branch August 8, 2020 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants