trying to fix model errors

This commit is contained in:
Khalim Conn-Kowlessar 2025-07-22 19:36:00 +01:00
parent 669f18acbc
commit 12c9ed1670
3 changed files with 6 additions and 2 deletions

View file

@ -48,7 +48,7 @@ from etl.find_my_epc.RetrieveFindMyEpc import RetrieveFindMyEpc
logger = setup_logger()
BATCH_SIZE = 5
SCORING_BATCH_SIZE = 400
SCORING_BATCH_SIZE = 100
def patch_epc(patch, epc_records):

View file

@ -11,7 +11,6 @@ def handler(event, context):
"""
Lambda handler that triggers the model engine for each SQS message.
"""
logger.info("Received event: %s", json.dumps(event, indent=2))
for record in event.get("Records", []):
try:
body_dict = json.loads(record["body"])

View file

@ -143,6 +143,9 @@ class ModelApi:
async with session.post(
url, json=payload, headers={"Content-Type": "application/json"}, timeout=120
) as response:
text = await response.text()
if response.status != 200:
logger.error(f"{model_prefix} | Status {response.status} | Body:\n{text}")
response.raise_for_status()
return await response.json()
except aiohttp.ClientError as e:
@ -218,7 +221,9 @@ class ModelApi:
async with aiohttp.ClientSession() as session:
for model_prefix in model_prefixes:
logger.info(f"Scoring for model prefix: {model_prefix}")
logger.info("Uploading scoring data to S3")
file_location = self.upload_scoring_data(df, bucket, model_prefix)
logger.info("Data uploaded to S3, now making prediction request")
# Schedule the prediction request as a coroutine
tasks.append(
self.predict_async(f"s3://{bucket}/" + file_location, model_prefix)