mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
refactor(ara): rename FirstRunPipeline → AraFirstRunPipeline (PR #1139 review)
Aligns the composition with its entry point (the `ara_first_run` lambda + `AraFirstRunTriggerBody`): clearer what the file does. - orchestration/first_run_pipeline.py → ara_first_run_pipeline.py - FirstRunPipeline → AraFirstRunPipeline; FirstRunCommand → AraFirstRunCommand - test files renamed to match Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
d89983d44f
commit
1ea71a3acb
5 changed files with 16 additions and 16 deletions
|
|
@ -14,7 +14,7 @@ from domain.property_baseline.rebaseliner import StubRebaseliner
|
||||||
from infrastructure.postgres.config import PostgresConfig
|
from infrastructure.postgres.config import PostgresConfig
|
||||||
from infrastructure.postgres.engine import make_engine
|
from infrastructure.postgres.engine import make_engine
|
||||||
from orchestration.property_baseline_orchestrator import PropertyBaselineOrchestrator
|
from orchestration.property_baseline_orchestrator import PropertyBaselineOrchestrator
|
||||||
from orchestration.first_run_pipeline import FirstRunPipeline
|
from orchestration.ara_first_run_pipeline import AraFirstRunPipeline
|
||||||
from orchestration.ingestion_orchestrator import (
|
from orchestration.ingestion_orchestrator import (
|
||||||
EpcFetcher,
|
EpcFetcher,
|
||||||
IngestionOrchestrator,
|
IngestionOrchestrator,
|
||||||
|
|
@ -42,7 +42,7 @@ def _get_engine() -> Engine:
|
||||||
|
|
||||||
|
|
||||||
class _RunsFirstRun(Protocol):
|
class _RunsFirstRun(Protocol):
|
||||||
"""The slice of FirstRunPipeline the handler delegates to."""
|
"""The slice of AraFirstRunPipeline the handler delegates to."""
|
||||||
|
|
||||||
def run(self, command: AraFirstRunTriggerBody) -> None: ...
|
def run(self, command: AraFirstRunTriggerBody) -> None: ...
|
||||||
|
|
||||||
|
|
@ -63,7 +63,7 @@ def build_first_run_pipeline(
|
||||||
epc_fetcher: EpcFetcher,
|
epc_fetcher: EpcFetcher,
|
||||||
geospatial_repo: GeospatialRepository,
|
geospatial_repo: GeospatialRepository,
|
||||||
solar_fetcher: SolarFetcher,
|
solar_fetcher: SolarFetcher,
|
||||||
) -> FirstRunPipeline:
|
) -> AraFirstRunPipeline:
|
||||||
"""Compose the real three-stage pipeline on a Unit-of-Work factory.
|
"""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
|
Each stage opens its own unit(s) and commits per batch (ADR-0012); the
|
||||||
|
|
@ -71,7 +71,7 @@ def build_first_run_pipeline(
|
||||||
their config is not settled — see ``_source_clients_from_env``. Modelling is
|
their config is not settled — see ``_source_clients_from_env``. Modelling is
|
||||||
stubbed (#1136); its Scenario / Materials ports are seams.
|
stubbed (#1136); its Scenario / Materials ports are seams.
|
||||||
"""
|
"""
|
||||||
return FirstRunPipeline(
|
return AraFirstRunPipeline(
|
||||||
ingestion=IngestionOrchestrator(
|
ingestion=IngestionOrchestrator(
|
||||||
unit_of_work=unit_of_work,
|
unit_of_work=unit_of_work,
|
||||||
epc_fetcher=epc_fetcher,
|
epc_fetcher=epc_fetcher,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
from typing import Protocol
|
from typing import Protocol
|
||||||
|
|
||||||
|
|
||||||
class FirstRunCommand(Protocol):
|
class AraFirstRunCommand(Protocol):
|
||||||
"""The slice of the trigger the pipeline threads downstream.
|
"""The slice of the trigger the pipeline threads downstream.
|
||||||
|
|
||||||
Only the business fields — UPRNs and Scenario definitions are read from
|
Only the business fields — UPRNs and Scenario definitions are read from
|
||||||
|
|
@ -41,7 +41,7 @@ class ModellingStage(Protocol):
|
||||||
def run(self, property_ids: list[int], scenario_ids: list[int]) -> None: ...
|
def run(self, property_ids: list[int], scenario_ids: list[int]) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
class FirstRunPipeline:
|
class AraFirstRunPipeline:
|
||||||
"""Composes the First Run stages end-to-end: Ingestion -> Baseline ->
|
"""Composes the First Run stages end-to-end: Ingestion -> Baseline ->
|
||||||
Modelling.
|
Modelling.
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ class FirstRunPipeline:
|
||||||
self._baseline = baseline
|
self._baseline = baseline
|
||||||
self._modelling = modelling
|
self._modelling = modelling
|
||||||
|
|
||||||
def run(self, command: FirstRunCommand) -> None:
|
def run(self, command: AraFirstRunCommand) -> None:
|
||||||
self._ingestion.run(command.property_ids)
|
self._ingestion.run(command.property_ids)
|
||||||
self._baseline.run(command.property_ids)
|
self._baseline.run(command.property_ids)
|
||||||
self._modelling.run(command.property_ids, command.scenario_ids)
|
self._modelling.run(command.property_ids, command.scenario_ids)
|
||||||
|
|
@ -7,16 +7,16 @@ from applications.ara_first_run.ara_first_run_trigger_body import (
|
||||||
AraFirstRunTriggerBody,
|
AraFirstRunTriggerBody,
|
||||||
)
|
)
|
||||||
from applications.ara_first_run.handler import dispatch_first_run
|
from applications.ara_first_run.handler import dispatch_first_run
|
||||||
from orchestration.first_run_pipeline import FirstRunCommand
|
from orchestration.ara_first_run_pipeline import AraFirstRunCommand
|
||||||
|
|
||||||
|
|
||||||
class _SpyPipeline:
|
class _SpyPipeline:
|
||||||
"""Records the command it is asked to run, instead of composing stages."""
|
"""Records the command it is asked to run, instead of composing stages."""
|
||||||
|
|
||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
self.received: Optional[FirstRunCommand] = None
|
self.received: Optional[AraFirstRunCommand] = None
|
||||||
|
|
||||||
def run(self, command: FirstRunCommand) -> None:
|
def run(self, command: AraFirstRunCommand) -> None:
|
||||||
self.received = command
|
self.received = command
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@ from __future__ import annotations
|
||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
|
||||||
from orchestration.first_run_pipeline import FirstRunCommand, FirstRunPipeline
|
from orchestration.ara_first_run_pipeline import AraFirstRunCommand, AraFirstRunPipeline
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
class _FakeCommand:
|
class _FakeCommand:
|
||||||
"""A stand-in for AraFirstRunTriggerBody — structurally a FirstRunCommand."""
|
"""A stand-in for AraFirstRunTriggerBody — structurally a AraFirstRunCommand."""
|
||||||
|
|
||||||
portfolio_id: int
|
portfolio_id: int
|
||||||
property_ids: list[int]
|
property_ids: list[int]
|
||||||
|
|
@ -41,10 +41,10 @@ class _SpyModelling:
|
||||||
def test_run_sequences_the_three_stages_threading_only_property_ids() -> None:
|
def test_run_sequences_the_three_stages_threading_only_property_ids() -> None:
|
||||||
# Arrange
|
# Arrange
|
||||||
log: list[tuple[object, ...]] = []
|
log: list[tuple[object, ...]] = []
|
||||||
command: FirstRunCommand = _FakeCommand(
|
command: AraFirstRunCommand = _FakeCommand(
|
||||||
portfolio_id=1, property_ids=[10, 11], scenario_ids=[7]
|
portfolio_id=1, property_ids=[10, 11], scenario_ids=[7]
|
||||||
)
|
)
|
||||||
pipeline = FirstRunPipeline(
|
pipeline = AraFirstRunPipeline(
|
||||||
ingestion=_SpyIngestion(log),
|
ingestion=_SpyIngestion(log),
|
||||||
baseline=_SpyBaseline(log),
|
baseline=_SpyBaseline(log),
|
||||||
modelling=_SpyModelling(log),
|
modelling=_SpyModelling(log),
|
||||||
|
|
@ -26,7 +26,7 @@ from infrastructure.postgres.property_baseline_performance_table import (
|
||||||
from infrastructure.postgres.epc_property_table import EpcPropertyModel
|
from infrastructure.postgres.epc_property_table import EpcPropertyModel
|
||||||
from infrastructure.postgres.property_table import PropertyRow
|
from infrastructure.postgres.property_table import PropertyRow
|
||||||
from orchestration.property_baseline_orchestrator import PropertyBaselineOrchestrator
|
from orchestration.property_baseline_orchestrator import PropertyBaselineOrchestrator
|
||||||
from orchestration.first_run_pipeline import FirstRunPipeline
|
from orchestration.ara_first_run_pipeline import AraFirstRunPipeline
|
||||||
from orchestration.ingestion_orchestrator import IngestionOrchestrator
|
from orchestration.ingestion_orchestrator import IngestionOrchestrator
|
||||||
from orchestration.modelling_orchestrator import ModellingOrchestrator
|
from orchestration.modelling_orchestrator import ModellingOrchestrator
|
||||||
from repositories.property_baseline.property_baseline_postgres_repository import (
|
from repositories.property_baseline.property_baseline_postgres_repository import (
|
||||||
|
|
@ -103,7 +103,7 @@ def test_first_run_baselines_through_repos_and_is_idempotent_on_rerun(
|
||||||
def unit_of_work() -> PostgresUnitOfWork:
|
def unit_of_work() -> PostgresUnitOfWork:
|
||||||
return PostgresUnitOfWork(lambda: Session(db_engine))
|
return PostgresUnitOfWork(lambda: Session(db_engine))
|
||||||
|
|
||||||
pipeline = FirstRunPipeline(
|
pipeline = AraFirstRunPipeline(
|
||||||
ingestion=IngestionOrchestrator(
|
ingestion=IngestionOrchestrator(
|
||||||
unit_of_work=unit_of_work,
|
unit_of_work=unit_of_work,
|
||||||
epc_fetcher=_FetcherReturning(_lodged_epc()),
|
epc_fetcher=_FetcherReturning(_lodged_epc()),
|
||||||
Loading…
Add table
Reference in a new issue