Creating Endpoint on Vertex AI using FastAPI, stuck at "GET /health HTTP/1.1" 404

653 Views Asked by At
Run at startup - downloads the model
@app.on_event("startup")
def startup():
path = os.environ["AIP_STORAGE_URI"]
path = os.path.join(path, model_file)
logger.info(f"Loading model state from: {path}")

if path.startswith("gs://"):
        destination_file_name = f"/tmp/{model_file}"
        storage_client = storage.Client()
        with open(destination_file_name, "wb") as file:
            # Download file from GCP
            storage_client.download_blob_to_file(path, file)

    else:
        logger.info("Local path...")
        destination_file_name = path
    
    model_files = joblib.load(destination_file_name)
    global_items["model"] = model_files


    logger.info("State successfully retrieved from GCP")



@app.get("/health")
async def health_check():
    """Health check endpoint."""
    return Response("healthy", status_code=status.HTTP_200_OK)


# Define prediction request logic
@app.get("/predict")
async def prediction(data: Data):
    """Make predictions"""
    try:

    except Exception as error:

    finally:


if __name__ == "__name__":
    uvicorn.run(app, host="0.0.0.0", port=8080, reload=False, log_level="info")

Using a model from the model registry and Image that has the following code. Endpoint is logs up until logger.info("State successfully retrieved from GCP") but gets stuck afterwards on uvicorn.access:send:480 - 10.20.3.1:33074 - "GET /health HTTP/1.1" 404..

Please help on how to get the health check right, if that's the problem. Thanks

0

There are 0 best solutions below