mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-12 13:29:04 +00:00
Merge pull request #1259 from Hestia-Homes/e2e-modelling-handler-returns-taskid
Task Handler handler returns task ID and subtask ID. Also remove broken recommendation
This commit is contained in:
commit
ad86f34701
2 changed files with 10 additions and 6 deletions
|
|
@ -284,10 +284,12 @@ def handler(body: dict[str, Any], context: Any) -> None:
|
||||||
|
|
||||||
# secondary_heating_removal is absent from the live material.type
|
# secondary_heating_removal is absent from the live material.type
|
||||||
# enum; exclude unconditionally until the catalogue gap is resolved.
|
# enum; exclude unconditionally until the catalogue gap is resolved.
|
||||||
|
# system_tune_up and system_tune_up_zoned have no active product.
|
||||||
considered: Optional[frozenset[MeasureType]] = (
|
considered: Optional[frozenset[MeasureType]] = (
|
||||||
frozenset(MeasureType)
|
frozenset(MeasureType)
|
||||||
- {MeasureType.SECONDARY_HEATING_REMOVAL}
|
- {MeasureType.SECONDARY_HEATING_REMOVAL}
|
||||||
- {MeasureType.SYSTEM_TUNE_UP_ZONED}
|
- {MeasureType.SYSTEM_TUNE_UP_ZONED}
|
||||||
|
- {MeasureType.SYSTEM_TUNE_UP}
|
||||||
)
|
)
|
||||||
|
|
||||||
plan = run_modelling(
|
plan = run_modelling(
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ def task_handler(
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
def wrapper(event: dict[str, Any], context: Any) -> Any:
|
def wrapper(event: dict[str, Any], context: Any) -> Any:
|
||||||
with factory() as orchestrator:
|
with factory() as orchestrator:
|
||||||
results: list[Any] = []
|
task_ids: list[dict[str, str]] = []
|
||||||
failures: list[dict[str, Any]] = []
|
failures: list[dict[str, Any]] = []
|
||||||
|
|
||||||
for record in _records(event):
|
for record in _records(event):
|
||||||
|
|
@ -52,19 +52,21 @@ def task_handler(
|
||||||
str(raw_source_id) if raw_source_id is not None else None
|
str(raw_source_id) if raw_source_id is not None else None
|
||||||
)
|
)
|
||||||
|
|
||||||
_, subtask = orchestrator.create_task_with_subtask(
|
task, subtask = orchestrator.create_task_with_subtask(
|
||||||
task_source=task_source,
|
task_source=task_source,
|
||||||
inputs=body,
|
inputs=body,
|
||||||
source=source,
|
source=source,
|
||||||
source_id=source_id,
|
source_id=source_id,
|
||||||
)
|
)
|
||||||
|
task_ids.append(
|
||||||
|
{"task_id": str(task.id), "subtask_id": str(subtask.id)}
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
result = orchestrator.run_subtask(
|
orchestrator.run_subtask(
|
||||||
subtask.id,
|
subtask.id,
|
||||||
work=lambda body=body: func(body, context),
|
work=lambda body=body: func(body, context),
|
||||||
)
|
)
|
||||||
results.append(result)
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception(
|
logger.exception(
|
||||||
"subtask failed (task_source=%s source_id=%s)",
|
"subtask failed (task_source=%s source_id=%s)",
|
||||||
|
|
@ -78,8 +80,8 @@ def task_handler(
|
||||||
raise
|
raise
|
||||||
|
|
||||||
if "Records" in event:
|
if "Records" in event:
|
||||||
return {"batchItemFailures": failures}
|
return {"batchItemFailures": failures, "tasks": task_ids}
|
||||||
return results
|
return task_ids
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue