mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Wires slice 1-5 primitives into a deployable splitter:
- orchestration/postcode_splitter_orchestrator.py: PostcodeSplitterOrchestrator
loads addresses via UserAddressRepository, groups by postcode via
iter_postcode_grouped_batches, persists each batch under
ara_postcode_splitter_batches/{task_id}/{subtask_id}/, creates a WAITING
child SubTask, and publishes an address2UPRN SQS message per batch.
- applications/postcode_splitter/: Lambda entrypoint. handler.py is decorated
with @subtask_handler() so the parent SubTask lifecycle is decorator-owned;
PostcodeSplitterTriggerBody validates the body. Dockerfile is the
python:3.11 Lambda base with the DDD-shaped source layers and no pandas.
- tests/orchestration/test_postcode_splitter_orchestrator.py: integration
test using moto S3 + moto SQS + in-memory SQLite that exercises the full
wiring against a fixture CSV spanning three postcode groups (one
oversize) and asserts child count, persisted inputs, queue bodies, and
dispatch order.
backend/postcode_splitter/ and .github/workflows/deploy_terraform.yml are
intentionally unchanged: the dockerfile_path flip is deferred until the
companion backend/address2UPRN/ migration is also ready.
32 lines
1.1 KiB
Python
32 lines
1.1 KiB
Python
"""Trigger payload model for the postcode splitter Lambda.
|
|
|
|
The decorator (``@subtask_handler``) already validates ``task_id`` and
|
|
``sub_task_id`` via :class:`SubtaskTriggerBody`; this model layers on the
|
|
splitter-specific ``s3_uri`` field while keeping ``extra="allow"`` so any
|
|
upstream-passthrough keys (e.g. ``portfolio_id``) survive untouched.
|
|
"""
|
|
|
|
from uuid import UUID
|
|
|
|
from pydantic import BaseModel, ConfigDict
|
|
|
|
|
|
class PostcodeSplitterTriggerBody(BaseModel):
|
|
"""Validated body for the postcode splitter Lambda.
|
|
|
|
Attributes:
|
|
task_id: Parent ``Task`` id; used as the ``task_id`` input on each
|
|
child ``SubTask`` and as the ``parent_task_id`` on the fan-out
|
|
SQS messages.
|
|
sub_task_id: The splitter's own ``SubTask`` id; used as the path
|
|
segment under ``ara_postcode_splitter_batches/{task_id}/{...}``
|
|
so per-invocation outputs cannot collide.
|
|
s3_uri: ``s3://bucket/key`` URI of the uploaded address CSV the
|
|
splitter must read.
|
|
"""
|
|
|
|
model_config = ConfigDict(extra="allow")
|
|
|
|
task_id: UUID
|
|
sub_task_id: UUID
|
|
s3_uri: str
|