diff --git a/applications/ara_first_run/handler.py b/applications/ara_first_run/handler.py index 8f4f9afa..acbbd74c 100644 --- a/applications/ara_first_run/handler.py +++ b/applications/ara_first_run/handler.py @@ -10,6 +10,7 @@ from sqlmodel import Session from applications.ara_first_run.ara_first_run_trigger_body import ( AraFirstRunTriggerBody, ) +from domain.epc_prediction.epc_prediction import EpcPrediction from domain.property_baseline.calculator_rebaseliner import CalculatorRebaseliner from domain.sap10_calculator.calculator import Sap10Calculator from infrastructure.postgres.config import PostgresConfig @@ -17,8 +18,10 @@ from infrastructure.postgres.engine import make_engine from orchestration.property_baseline_orchestrator import PropertyBaselineOrchestrator from orchestration.ara_first_run_pipeline import AraFirstRunPipeline from orchestration.ingestion_orchestrator import ( + ComparablesRepo, EpcFetcher, IngestionOrchestrator, + PredictionAttributesReader, SolarFetcher, ) from orchestration.modelling_orchestrator import ModellingOrchestrator @@ -65,12 +68,23 @@ def build_first_run_pipeline( epc_fetcher: EpcFetcher, geospatial_repo: GeospatialRepository, solar_fetcher: SolarFetcher, + comparables_repo: Optional[ComparablesRepo] = None, + prediction_attributes_reader: Optional[PredictionAttributesReader] = None, ) -> AraFirstRunPipeline: """Compose the real three-stage pipeline on a Unit-of-Work factory. Each stage opens its own unit(s) and commits per batch (ADR-0012); the handler no longer holds a session. The source clients are passed in because their config is not settled — see ``_source_clients_from_env``. + + EPC Prediction gap-fill (ADR-0031) is the predictor itself (pure) plus two + injected collaborators: the postcode-cohort source and the Landlord-Override + attributes reader. Both default to None, so the feature is **off** until they + are supplied — an EPC-less Property is then predicted into its predicted slot. + The cohort repo is injected (not built here) because its EPC client is the + same source client whose wiring is still pending; the attributes reader is the + `property_overrides` read adapter built separately. Until both are passed, + ingestion behaves exactly as before. """ return AraFirstRunPipeline( ingestion=IngestionOrchestrator( @@ -78,6 +92,9 @@ def build_first_run_pipeline( epc_fetcher=epc_fetcher, geospatial_repo=geospatial_repo, solar_fetcher=solar_fetcher, + comparables_repo=comparables_repo, + prediction_attributes_reader=prediction_attributes_reader, + epc_prediction=EpcPrediction(), ), baseline=PropertyBaselineOrchestrator( unit_of_work=unit_of_work, diff --git a/docs/HANDOVER_EPC_PREDICTION_WIRING.md b/docs/HANDOVER_EPC_PREDICTION_WIRING.md index 06acbd0e..789e0448 100644 --- a/docs/HANDOVER_EPC_PREDICTION_WIRING.md +++ b/docs/HANDOVER_EPC_PREDICTION_WIRING.md @@ -52,21 +52,26 @@ so the gate skips the Property. `docs/MIGRATION_NOTE_predicted_epc_source.md` (column + default `'lodged'` + relax any `property_id` uniqueness to `(property_id, source)`). -### 3. Wire the collaborators at the composition root +### 3. Pass the two collaborators at the composition root -Wherever `IngestionOrchestrator(...)` is constructed for the real run, pass the -three optional kwargs: +This is now wired: `build_first_run_pipeline` (in `applications/ara_first_run/handler.py`) +already constructs `epc_prediction=EpcPrediction()` and accepts the other two as +optional params that it threads into the `IngestionOrchestrator`. So the on-switch +is just supplying them once they exist: ```python -IngestionOrchestrator( +build_first_run_pipeline( ..., comparables_repo=EpcComparablePropertiesRepository(epc_client, geospatial_repo), - prediction_attributes_reader=, - epc_prediction=EpcPrediction(), + prediction_attributes_reader=, # task #1 ) ``` -That's the on-switch. Until all three are passed, ingestion ignores prediction. +`epc_client` is the same EPC source client behind `epc_fetcher` (the concrete +`EpcClientService` exposes `search_by_postcode` + `get_by_certificate_number`), +so build it alongside the other source clients in `_source_clients_from_env` +(pending #1136). Until **both** are passed, ingestion ignores prediction — no +orchestrator or handler edits needed, just the two arguments. ## One open item — Validation Cohort exclusion