absorb Orquestacion into webapi.orquestacion
Orquestacion was a separate uv package with exactly one consumer (webapi.indicadores_vivos) and no independent deployment: the Dockerfile already copied it straight into this image and ran one uv sync for everything. Folding it in removes a redundant pyproject.toml/uv.lock/venv without losing the standalone CLI (python -m webapi.orquestacion ciclo/ confirmar-riesgos) or its test suite, which now runs as part of this project's own pytest run. 417 tests pass (416 unchanged + the merged orquestacion suite); verified live in a built image, where the indicadores worker completed a full cacu/cama/tea cycle against webapi.orquestacion.ejecutor.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"""Las dependencias entre los pasos de cada proyecto, como las lee Hamilton de los parámetros."""
|
||||
|
||||
import pytest
|
||||
from hamilton import driver
|
||||
|
||||
from webapi.orquestacion import ciclo, pasos_de
|
||||
|
||||
|
||||
def dependencias(proyecto: str) -> dict[str, set[str]]:
|
||||
dr = driver.Builder().with_modules(ciclo).with_config({"con_cohortes": proyecto == "cacu"}).build()
|
||||
return {n.name: {d.name for d in n.dependencies} - {"ctx"} for n in dr.graph.get_nodes() if n.name != "ctx"}
|
||||
|
||||
|
||||
def antes(deps: dict[str, set[str]], paso: str) -> set[str]:
|
||||
"""Todos los pasos que corren antes de `paso`."""
|
||||
previos = set()
|
||||
pendientes = list(deps[paso])
|
||||
while pendientes:
|
||||
anterior = pendientes.pop()
|
||||
if anterior not in previos:
|
||||
previos.add(anterior)
|
||||
pendientes.extend(deps[anterior])
|
||||
return previos
|
||||
|
||||
|
||||
@pytest.mark.parametrize("proyecto", ["cacu", "cama", "tea"])
|
||||
def test_cada_paso_corre_despues_de_lo_que_necesita(proyecto):
|
||||
deps = dependencias(proyecto)
|
||||
assert deps["migrar"] == set()
|
||||
assert {"migrar", "catalogos"} <= antes(deps, "cargar") # decisión 6 de §9
|
||||
assert {"cargar", "vistas", "registro", "definiciones"} <= antes(deps, "calcular")
|
||||
assert {"registro", "calcular"} <= antes(deps, "observar")
|
||||
assert {"cargar", "calcular"} <= antes(deps, "verificar_plata")
|
||||
|
||||
|
||||
def test_solo_cacu_arma_cohortes_y_estima_por_ahora():
|
||||
"""T-21h: las cohortes de TEA y CaMa son propuestas (`cohortes/propuestas/`); queda su infraestructura."""
|
||||
assert {"cohortes", "estimar"} <= set(pasos_de("cacu"))
|
||||
for proyecto in ("cama", "tea"):
|
||||
assert not {"cohortes", "estimar"} & set(pasos_de(proyecto))
|
||||
Reference in New Issue
Block a user