mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-22 08:48:38 +00:00
A task that already has sub_tasks refuses re-distribution 🟩
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
dade7a3a5f
commit
cfedb8e9cf
1 changed files with 11 additions and 2 deletions
|
|
@ -12,7 +12,7 @@ from collections.abc import Callable, Iterator
|
||||||
from typing import Any, cast
|
from typing import Any, cast
|
||||||
|
|
||||||
import boto3
|
import boto3
|
||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
from sqlmodel import Session
|
from sqlmodel import Session
|
||||||
|
|
||||||
from backend.app.config import get_settings
|
from backend.app.config import get_settings
|
||||||
|
|
@ -70,6 +70,16 @@ async def trigger_run(
|
||||||
session: Session = Depends(get_session),
|
session: Session = Depends(get_session),
|
||||||
send_messages: MessageSender = Depends(get_message_sender),
|
send_messages: MessageSender = Depends(get_message_sender),
|
||||||
) -> dict[str, str]:
|
) -> dict[str, str]:
|
||||||
|
subtask_repo = SubTaskPostgresRepository(session)
|
||||||
|
if subtask_repo.list_by_task(body.task_id):
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=409,
|
||||||
|
detail=(
|
||||||
|
f"Task {body.task_id} already has sub_tasks — it has been "
|
||||||
|
"distributed. Check its progress instead of re-triggering."
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
properties: list[FilteredProperty] = resolve_filtered_property_ids(
|
properties: list[FilteredProperty] = resolve_filtered_property_ids(
|
||||||
session, body.portfolio_id, body.filters
|
session, body.portfolio_id, body.filters
|
||||||
)
|
)
|
||||||
|
|
@ -78,7 +88,6 @@ async def trigger_run(
|
||||||
# Pre-create one sub_task per (scenario, batch) message under the
|
# Pre-create one sub_task per (scenario, batch) message under the
|
||||||
# app-owned task, each holding its exact message payload — the fixed
|
# app-owned task, each holding its exact message payload — the fixed
|
||||||
# progress denominator and the batch's re-run recipe (ADR-0055).
|
# progress denominator and the batch's re-run recipe (ADR-0055).
|
||||||
subtask_repo = SubTaskPostgresRepository(session)
|
|
||||||
subtasks: list[SubTask] = []
|
subtasks: list[SubTask] = []
|
||||||
payloads: list[dict[str, Any]] = []
|
payloads: list[dict[str, Any]] = []
|
||||||
for scenario_id in body.scenario_ids:
|
for scenario_id in body.scenario_ids:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue