mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-07-22 08:48:38 +00:00
add local handler and orchestrator
This commit is contained in:
parent
78673e96f7
commit
a7ecb0eaec
3 changed files with 97 additions and 0 deletions
|
|
@ -0,0 +1,11 @@
|
||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
audit-generator-lambda:
|
||||||
|
build:
|
||||||
|
context: ../../../
|
||||||
|
dockerfile: applications/audit_generator/handler/Dockerfile
|
||||||
|
ports:
|
||||||
|
- "9001:8080"
|
||||||
|
env_file:
|
||||||
|
- ../../../.env
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
import json
|
||||||
|
import requests
|
||||||
|
|
||||||
|
HOST = "localhost"
|
||||||
|
PORT = "9001"
|
||||||
|
|
||||||
|
LAMBDA_URL = f"http://{HOST}:{PORT}/2015-03-31/functions/function/invocations"
|
||||||
|
|
||||||
|
payload = {
|
||||||
|
"Records": [
|
||||||
|
{
|
||||||
|
"messageId": "test-message-id",
|
||||||
|
"body": json.dumps(
|
||||||
|
{
|
||||||
|
"task_id": "00000000-0000-0000-0000-000000000001",
|
||||||
|
"sub_task_id": "00000000-0000-0000-0000-000000000002",
|
||||||
|
"hubspot_deal_id": "500311510234",
|
||||||
|
}
|
||||||
|
),
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
response = requests.post(LAMBDA_URL, json=payload)
|
||||||
|
|
||||||
|
print("Status code:", response.status_code)
|
||||||
|
print("Response:")
|
||||||
|
print(response.text)
|
||||||
|
|
@ -0,0 +1,57 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Run AuditGeneratorOrchestrator directly, bypassing @subtask_handler.
|
||||||
|
|
||||||
|
Loads credentials from the repo-root .env file so no DB task/subtask rows
|
||||||
|
are needed.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from pathlib import Path
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
|
import boto3
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
|
||||||
|
REPO_ROOT = Path(__file__).resolve().parents[3]
|
||||||
|
load_dotenv(REPO_ROOT / ".env")
|
||||||
|
|
||||||
|
sys.path.insert(0, str(REPO_ROOT))
|
||||||
|
|
||||||
|
from utilities.logger import setup_logger
|
||||||
|
|
||||||
|
setup_logger()
|
||||||
|
|
||||||
|
from infrastructure.postgres.config import PostgresConfig
|
||||||
|
from infrastructure.postgres.engine import make_engine, make_session
|
||||||
|
from infrastructure.s3.s3_client import S3Client
|
||||||
|
from orchestration.audit_generator_orchestrator import AuditGeneratorOrchestrator
|
||||||
|
from orchestration.audit_generator_unit_of_work import AuditGeneratorUnitOfWork
|
||||||
|
|
||||||
|
HUBSPOT_DEAL_ID = "505712829658"
|
||||||
|
|
||||||
|
boto3_client: Any = boto3.client # type: ignore[attr-defined]
|
||||||
|
s3_client = S3Client(
|
||||||
|
boto_s3_client=boto3_client("s3"),
|
||||||
|
# bucket=os.environ["S3_BUCKET_NAME"],
|
||||||
|
bucket="retrofit-energy-assessments-dev",
|
||||||
|
)
|
||||||
|
|
||||||
|
engine = make_engine(PostgresConfig.from_env(os.environ))
|
||||||
|
|
||||||
|
|
||||||
|
def session_factory() -> Any:
|
||||||
|
return make_session(engine)
|
||||||
|
|
||||||
|
|
||||||
|
def uow_factory() -> AuditGeneratorUnitOfWork:
|
||||||
|
return AuditGeneratorUnitOfWork(session_factory)
|
||||||
|
|
||||||
|
|
||||||
|
print(f"Running AuditGeneratorOrchestrator for deal: {HUBSPOT_DEAL_ID!r}")
|
||||||
|
AuditGeneratorOrchestrator(
|
||||||
|
hubspot_deal_id=HUBSPOT_DEAL_ID,
|
||||||
|
s3_client=s3_client,
|
||||||
|
uow_factory=uow_factory,
|
||||||
|
).run()
|
||||||
|
print("Done")
|
||||||
Loading…
Add table
Reference in a new issue