모델 로딩 시간 기록하기
펭귄을 분류하는 FastAPI 앱을 개발 중입니다. 모델을 로딩하는 데 걸리는 시간을 측정하고 로그로 기록해 보세요.
이 연습은 강의의 일부입니다
FastAPI로 AI 프로덕션 배포하기
연습 안내
uvicorn오류 로거를 불러오세요.- 모델 로딩 처리 시간을 INFO 레벨로 기록하세요.
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
from fastapi import FastAPI
import logging
import joblib
import time
# Get the uvicorn error logger
logger = logging.getLogger('____')
start_time = time.perf_counter()
model = joblib.load('penguin_classifier.pkl')
process_time = time.perf_counter() - start_time
# Log the process time at the INFO level
logger.____(f"Process time was {____} seconds.")
app = FastAPI()