mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +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
|
||||
# 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]] = (
|
||||
frozenset(MeasureType)
|
||||
- {MeasureType.SECONDARY_HEATING_REMOVAL}
|
||||
- {MeasureType.SYSTEM_TUNE_UP_ZONED}
|
||||
- {MeasureType.SYSTEM_TUNE_UP}
|
||||
)
|
||||
|
||||
plan = run_modelling(
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ def task_handler(
|
|||
@wraps(func)
|
||||
def wrapper(event: dict[str, Any], context: Any) -> Any:
|
||||
with factory() as orchestrator:
|
||||
results: list[Any] = []
|
||||
task_ids: list[dict[str, str]] = []
|
||||
failures: list[dict[str, Any]] = []
|
||||
|
||||
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
|
||||
)
|
||||
|
||||
_, subtask = orchestrator.create_task_with_subtask(
|
||||
task, subtask = orchestrator.create_task_with_subtask(
|
||||
task_source=task_source,
|
||||
inputs=body,
|
||||
source=source,
|
||||
source_id=source_id,
|
||||
)
|
||||
task_ids.append(
|
||||
{"task_id": str(task.id), "subtask_id": str(subtask.id)}
|
||||
)
|
||||
|
||||
try:
|
||||
result = orchestrator.run_subtask(
|
||||
orchestrator.run_subtask(
|
||||
subtask.id,
|
||||
work=lambda body=body: func(body, context),
|
||||
)
|
||||
results.append(result)
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"subtask failed (task_source=%s source_id=%s)",
|
||||
|
|
@ -78,8 +80,8 @@ def task_handler(
|
|||
raise
|
||||
|
||||
if "Records" in event:
|
||||
return {"batchItemFailures": failures}
|
||||
return results
|
||||
return {"batchItemFailures": failures, "tasks": task_ids}
|
||||
return task_ids
|
||||
|
||||
return wrapper
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue