import wmill
from wmill import S3Object
import base64
import json
import requests

LOCAL_ENDPOINT = "http://127.0.0.1:8000/predict"

def main(input_file: S3Object):
    # Load image from S3
    s3_bytes = wmill.load_s3_file(input_file)
    payload = {"image_bytes": base64.b64encode(s3_bytes).decode("utf-8")}

    print("CALLING LOCAL ENDPOINT")

    response = requests.post(LOCAL_ENDPOINT, json=payload)
    result = response.json()

    print("RESULT RECEIVED")
    return result
