mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-30 13:10:47 +00:00
local runner and correct template path
This commit is contained in:
parent
e010fa1b40
commit
f8c955b2d3
2 changed files with 70 additions and 1 deletions
|
|
@ -19,7 +19,7 @@ from infrastructure.s3.s3_client import S3Client
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from orchestration.audit_generator_unit_of_work import AuditGeneratorUnitOfWork
|
from orchestration.audit_generator_unit_of_work import AuditGeneratorUnitOfWork
|
||||||
|
|
||||||
_TEMPLATE_PATH = Path(__file__).parent.parent / "applications" / "audit-generator" / "d1_ventilation_template.xlsx"
|
_TEMPLATE_PATH = Path(__file__).parent.parent / "applications" / "audit_generator" / "d1_ventilation_template.xlsx"
|
||||||
_SHEET_NAME = "D1 Ventilation"
|
_SHEET_NAME = "D1 Ventilation"
|
||||||
_DATA_START_ROW = 6
|
_DATA_START_ROW = 6
|
||||||
_MAX_ROWS = 50
|
_MAX_ROWS = 50
|
||||||
|
|
|
||||||
69
scripts/run_audit_generator_local.py
Normal file
69
scripts/run_audit_generator_local.py
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
"""
|
||||||
|
Run audit_generator locally. Writes XLSX to ./local_output/ instead of S3.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
cd /workspaces/model
|
||||||
|
python scripts/run_audit_generator_local.py <hubspot_deal_id>
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from io import BytesIO
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
# Load .env before importing infra modules
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
load_dotenv(Path(__file__).parent.parent / "backend" / ".env")
|
||||||
|
|
||||||
|
from infrastructure.postgres.config import PostgresConfig
|
||||||
|
from infrastructure.postgres.engine import make_engine, make_session
|
||||||
|
from orchestration.audit_generator_orchestrator import AuditGeneratorOrchestrator
|
||||||
|
from orchestration.audit_generator_unit_of_work import AuditGeneratorUnitOfWork
|
||||||
|
|
||||||
|
|
||||||
|
class _LocalS3Client:
|
||||||
|
"""Writes to local filesystem instead of S3."""
|
||||||
|
|
||||||
|
def __init__(self, output_dir: Path) -> None:
|
||||||
|
self._output_dir = output_dir
|
||||||
|
self._output_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def bucket(self) -> str:
|
||||||
|
return "local"
|
||||||
|
|
||||||
|
def get_object(self, key: str) -> bytes:
|
||||||
|
raise NotImplementedError
|
||||||
|
|
||||||
|
def put_object(self, key: str, body: bytes) -> str:
|
||||||
|
dest = self._output_dir / Path(key).name
|
||||||
|
dest.write_bytes(body)
|
||||||
|
print(f"Saved: {dest}")
|
||||||
|
return str(dest)
|
||||||
|
|
||||||
|
|
||||||
|
def main() -> None:
|
||||||
|
deal_id = sys.argv[1] if len(sys.argv) > 1 else input("hubspot_deal_id: ").strip()
|
||||||
|
output_dir = Path(__file__).parent.parent / "local_output"
|
||||||
|
|
||||||
|
engine = make_engine(PostgresConfig.from_env(os.environ))
|
||||||
|
|
||||||
|
def session_factory() -> Any:
|
||||||
|
return make_session(engine)
|
||||||
|
|
||||||
|
def uow_factory() -> AuditGeneratorUnitOfWork:
|
||||||
|
return AuditGeneratorUnitOfWork(session_factory)
|
||||||
|
|
||||||
|
AuditGeneratorOrchestrator(
|
||||||
|
hubspot_deal_id=deal_id,
|
||||||
|
s3_client=_LocalS3Client(output_dir), # type: ignore[arg-type]
|
||||||
|
uow_factory=uow_factory,
|
||||||
|
).run()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Loading…
Add table
Reference in a new issue