mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Merge pull request #464 from Hestia-Homes/debugging-api
added more detailed loging
This commit is contained in:
commit
99d8b5e00d
1 changed files with 19 additions and 5 deletions
|
|
@ -129,7 +129,7 @@ class ModelApi:
|
|||
|
||||
async def predict_async(self, file_location, model_prefix: str):
|
||||
"""Makes an asynchronous POST request to the Model API with the provided parameters."""
|
||||
logger.info(f"Making request to {model_prefix} change api")
|
||||
logger.info(f"Making request to {model_prefix} model API")
|
||||
url = f"{self.base_url}/{self.MODEL_URLS[model_prefix]}/predict"
|
||||
payload = {
|
||||
"file_location": file_location,
|
||||
|
|
@ -144,12 +144,26 @@ class ModelApi:
|
|||
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()
|
||||
logger.error(
|
||||
f"\n--- API ERROR [{model_prefix}] ---\n"
|
||||
f"Status Code: {response.status}\n"
|
||||
f"URL: {url}\n"
|
||||
f"Payload: {payload}\n"
|
||||
f"Response Text:\n{text}\n"
|
||||
f"----------------------------"
|
||||
)
|
||||
return None
|
||||
|
||||
# Successful response
|
||||
return aiohttp.helpers.json.loads(text)
|
||||
|
||||
except aiohttp.ClientError as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
logger.error(f"[{model_prefix}] HTTP error: {e}")
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.exception(f"[{model_prefix}] Unexpected error: {e}")
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue