Aan de slagGa gratis aan de slag

Logging time to load a model

You are building a FastAPI app to classify penguins, and you'd like measure the time it takes to load the model and log it.

Deze oefening maakt deel uit van de cursus

Deploying AI into Production with FastAPI

Cursus bekijken

Oefeninstructies

  • Load the uvicorn error logger.
  • Log the process time to load the model at the INFO level.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

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()
Code bewerken en uitvoeren