mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
preparing pre-flight requests
This commit is contained in:
parent
453f83f6b5
commit
42e447e416
2 changed files with 20 additions and 3 deletions
|
|
@ -43,6 +43,18 @@ async def trigger_plan_entrypoint(body: PlanTriggerRequest):
|
|||
logger.error("Failed to parse request body: %s", e)
|
||||
return {"message": "Invalid request"}, 400
|
||||
|
||||
# TODO: Warm up the lambdas here
|
||||
# from backend.ml_models.api import ModelApi
|
||||
# model_api = ModelApi(
|
||||
# portfolio_id=body.portfolio_id,
|
||||
# timestamp="2020-01-01T00:00:00",
|
||||
# prediction_buckets=[],
|
||||
# max_retries=1
|
||||
# )
|
||||
# await model_api.async_warm_up_lambdas(
|
||||
# model_prefies=model_api.KWH_MODEL_PREFIXES + model_api.MODEL_PREFIXES
|
||||
# )
|
||||
|
||||
# If file_format is domna_asset_list and type is xlsx, read and chunk it
|
||||
if data.get("file_format") == "domna_asset_list" and data.get("file_type") == "xlsx":
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -257,8 +257,10 @@ class ModelApi:
|
|||
model_prefixes = self.MODEL_PREFIXES if model_prefies is None else model_prefies
|
||||
session = self.get_aiohttp_session()
|
||||
tasks = [
|
||||
self._send_warm_up_request(session, f"{self.base_url}/{self.MODEL_URLS[model_prefix]}/predict",
|
||||
model_prefix)
|
||||
self._send_warm_up_request(
|
||||
session, f"{self.base_url}/{self.MODEL_URLS[model_prefix]}/predict",
|
||||
model_prefix
|
||||
)
|
||||
for model_prefix in model_prefixes
|
||||
]
|
||||
await asyncio.gather(*tasks, return_exceptions=True)
|
||||
|
|
@ -271,7 +273,10 @@ class ModelApi:
|
|||
"file_location": "s3://warm-up-placeholder",
|
||||
"portfolio_id": 0,
|
||||
"property_id": "",
|
||||
"created_at": "2020-01-01T00:00:00"
|
||||
"created_at": "2020-01-01T00:00:00",
|
||||
"warm": True
|
||||
# The presence of this key will send the api down a specific warm up route, to call
|
||||
# prediction and load the font manager, because that is a key bottleneck for cold starts
|
||||
}
|
||||
async with session.post(url, json=json_payload, timeout=10) as response:
|
||||
text = await response.text()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue