mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
added more detailed loging
This commit is contained in:
parent
5a348538b5
commit
2b4ac6ae53
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):
|
async def predict_async(self, file_location, model_prefix: str):
|
||||||
"""Makes an asynchronous POST request to the Model API with the provided parameters."""
|
"""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"
|
url = f"{self.base_url}/{self.MODEL_URLS[model_prefix]}/predict"
|
||||||
payload = {
|
payload = {
|
||||||
"file_location": file_location,
|
"file_location": file_location,
|
||||||
|
|
@ -144,12 +144,26 @@ class ModelApi:
|
||||||
url, json=payload, headers={"Content-Type": "application/json"}, timeout=120
|
url, json=payload, headers={"Content-Type": "application/json"}, timeout=120
|
||||||
) as response:
|
) as response:
|
||||||
text = await response.text()
|
text = await response.text()
|
||||||
|
|
||||||
if response.status != 200:
|
if response.status != 200:
|
||||||
logger.error(f"{model_prefix} | Status {response.status} | Body:\n{text}")
|
logger.error(
|
||||||
response.raise_for_status()
|
f"\n--- API ERROR [{model_prefix}] ---\n"
|
||||||
return await response.json()
|
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:
|
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
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue