feat: Add poblacion_apta service to docker-compose, enhance API gateway for new service integration, and update README with service details. Introduce new database tables for poblacion_apta_jobs and poblacion_apta_rows, and implement functionality for handling cop/mod calculations in the cleaning service.

This commit is contained in:
erik
2026-07-28 04:29:14 -05:00
parent 447359166b
commit e73e425e4b
47 changed files with 6978 additions and 84 deletions
+18 -2
View File
@@ -17,6 +17,7 @@ logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(name
EXTRACTION_URL = os.getenv("EXTRACTION_URL", "http://extraction:8001").rstrip("/")
CLEANING_URL = os.getenv("CLEANING_URL", "http://cleaning:8002").rstrip("/")
POBLACION_APTA_URL = os.getenv("POBLACION_APTA_URL", "http://poblacion_apta:8003").rstrip("/")
COUNT_URL = os.getenv("COUNT_URL", "http://count-api:8080").rstrip("/")
BOT_DESCARGA_URL = os.getenv("BOT_DESCARGA_URL", "http://bot-descarga:8200").rstrip("/")
@@ -35,9 +36,10 @@ async def lifespan(app: FastAPI):
limits=httpx.Limits(max_connections=100, max_keepalive_connections=20),
)
_log.info(
"Gateway iniciado — extraction=%s cleaning=%s count=%s bot_descarga=%s",
"Gateway iniciado — extraction=%s cleaning=%s poblacion_apta=%s count=%s bot_descarga=%s",
EXTRACTION_URL,
CLEANING_URL,
POBLACION_APTA_URL,
COUNT_URL,
BOT_DESCARGA_URL,
)
@@ -79,6 +81,8 @@ def _is_upload_path(path: str) -> bool:
or "/upload" in path
or path.startswith("/cleaning/analyze-csv")
or path.startswith("/cleaning/jobs/from-csv")
or path.startswith("/poblacion-apta/jobs/from-csv")
or path.startswith("/poblacion-apta/jobs/from-cleaning")
or path.startswith("/bot-descarga/jobs")
)
@@ -98,13 +102,15 @@ async def health() -> dict[str, Any]:
client = _client()
extraction = await _safe_health(client, EXTRACTION_URL)
cleaning = await _safe_health(client, CLEANING_URL)
poblacion_apta = await _safe_health(client, POBLACION_APTA_URL)
counting = await _safe_health(client, COUNT_URL)
bot_descarga = await _safe_health(client, BOT_DESCARGA_URL)
return {
"status": "ok" if extraction["ok"] and cleaning["ok"] else "degraded",
"status": "ok" if extraction["ok"] and cleaning["ok"] and poblacion_apta["ok"] else "degraded",
"services": {
"extraction": extraction,
"cleaning": cleaning,
"poblacion_apta": poblacion_apta,
"counting": counting,
"bot_descarga": bot_descarga,
},
@@ -116,6 +122,11 @@ async def models() -> Response:
return await _proxy("GET", f"{EXTRACTION_URL}/models")
@app.get("/openai/balance")
async def openai_balance() -> Response:
return await _proxy("GET", f"{EXTRACTION_URL}/openai/balance")
@app.get("/config")
async def config() -> dict[str, Any]:
client = _client()
@@ -147,6 +158,11 @@ async def cleaning_proxy(path: str, request: Request) -> Response:
return await _proxy_request(request, f"{CLEANING_URL}/{path}")
@app.api_route("/poblacion-apta/{path:path}", methods=["GET", "POST", "PUT", "PATCH", "DELETE"])
async def poblacion_apta_proxy(path: str, request: Request) -> Response:
return await _proxy_request(request, f"{POBLACION_APTA_URL}/{path}")
@app.api_route("/count/{path:path}", methods=["GET", "POST", "PUT", "PATCH", "DELETE"])
async def count_proxy(path: str, request: Request) -> Response:
return await _proxy_request(request, f"{COUNT_URL}/{path}")