feat(apps): archive vers Garage puis supprime les chunks anciens de reading

Nouveau module app.etl.reading_retention : pour chaque chunk de `reading` entièrement plus
vieux que APP_READING_RETENTION_DAYS (1095 jours), export CSV gzip reproductible vers Garage
(SSE-C, sha256 en métadonnées), relecture et comparaison, puis drop_chunks ciblé sur ce seul
chunk dans une transaction dédiée. --dry-run. Réglages APP_S3_* optionnels, jamais exigés par
l'API. DAG Airflow `retention` quotidien à 03h20. 44 tests unitaires sans réseau ni base,
tests d'intégrité du DAG, vérification --help dans l'image Airflow en CI. Docs 40-data et
20-backend.

Closes #36
This commit is contained in:
Johan LEROY
2026-09-24 10:36:09 +02:00
parent 0462dd01ba
commit fa815f49b6
10 changed files with 1292 additions and 14 deletions
+20
View File
@@ -18,6 +18,7 @@ DAG_IDS = [
"historical_import",
"mock_api_import",
"derive",
"retention",
]
TACHES = [
("ml_train", "train"),
@@ -27,6 +28,7 @@ TACHES = [
("historical_import", "import_historical"),
("mock_api_import", "import_mock_api"),
("derive", "derive"),
("retention", "archiver"),
]
@@ -228,6 +230,24 @@ def test_derive_never_retries_a_detected_drift(dagbag: DagBag) -> None:
assert dagbag.dags["derive"].get_task("derive").retries == 0
def test_retention_runs_nightly(dagbag: DagBag) -> None:
# Entre `ml_score` (:00), `alertes` (:15) et `mock_api_import` (:45) : drop_chunks verrouille
# reading, site et dataset jusqu'au COMMIT.
assert dagbag.dags["retention"].timetable.expression == "20 3 * * *"
def test_retention_calls_the_backend_retention_module(dagbag: DagBag) -> None:
commande = dagbag.dags["retention"].get_task("archiver").bash_command
assert "app.etl.reading_retention" in commande
def test_retention_runs_in_the_backend_environment(dagbag: DagBag) -> None:
commande = dagbag.dags["retention"].get_task("archiver").bash_command
assert "/opt/backend" in commande
@pytest.mark.parametrize(("dag_id", "task_id"), TACHES)
def test_tasks_never_resync_the_baked_environment(
dagbag: DagBag, dag_id: str, task_id: str