fix(mart): validazione multi-year — tabelle con years non bloccano il run (#445) - #446
Merged
Conversation
… run (issue #445) Gap 1 — validate.py: run_mart_validation esclude dalle required_tables per-anno le tabelle con mart.tables[].years (sono a livello dataset). Prima: Missing required MART tables falliva sempre il run con solo tabelle multi-year. Gap 2 — run.py: run_mart_multi_year valida le tabelle prodotte con validate_mart (table_rules/required_tables delle tabelle multi-year). Prima: nessuna validazione multi-year esisteva. Aggiunto esito nel metadata (layer mart_multi_year, field validation) e nel return (validation_passed/validation_errors). Gap 3 — cmd_run.py: quando has_single_year_mart è False (tutte le tabelle multi-year), registra una validazione mart 'skipped' (passed) per non far fallire il run per-anno. _maybe_run_multi_year_mart propaga validation_passed=False come errore (fail_on_error). Test: test_mart_only_multi_year — solo tabelle con years, run passa, output dataset-level, validazione multi-year applicata. Verifica reale: iva-regionale (tabelle miste) passa, 2 output multi-year validati (10 e 21 righe).
- run.py: multi_year_names tipizzato set[str] (filtra i None) - cmd_run.py: skipped_summary annotato dict[str, Any] Risolve i 2 errori mypy introdotti dal fix #445 (gli altri 89 errori residui sono pre-esistenti su main: arg-type su validate_mart/validate_clean e stub lab_connectors mancanti).
…skip - cmd_run.py: estratto _skip_mart_validation in helper — riduce le righe aggiunte a run_year (il numero di riga del logger.error cambiava e il rich logger spezzava 'CLEAN SQL' inserendo l'ancora in mezzo) - test_run_dry_run.py: assert robusti a 'CLEAN <ancora> SQL' (regex) — il wrap del logger dipende dal numero di riga, fragile tra versioni - run.py: import locale di validate_mart nella funzione (evita di caricare lo stack di validazione all'import del modulo) Verifica: test_run_dry_run 21/21 (su main e branch), test_mart_multi_year 2/2. Il comportamento del fix #445 è invariato.
…issue #445) - path_resolver.py: _mart_output_paths distingue per tabella — con years l'output è data/mart/{dataset}/{name}.parquet (dataset-level), senza years resta nel dir per-anno. Prima tutti gli output erano nel dir per-anno → readiness/summary segnalavano mart_outputs_missing per le multi-year anche quando esistevano. Verifica: review_readiness(iva-regionale) ora ready (8/8) invece di needs-review (7/8); summary warnings vuoto, 3/3 output. Test: test_mart_output_paths_multi_year_resolve_to_dataset_level — path resolver multi-year a livello dataset, isolato (no run, no CWD). Suite: test_mart_multi_year 3/3, test_cli_path_contract 23/23, test_run_dry_run 21/21, test_run_validation_gate 7/7. mypy 0 errori.
…ger robusti - test_mart_only_multi_year_validation_failure: table_rules violata in multi-year → run fallisce (validation_passed=False), metadata registra gli errori. Copre il ramo di errore prima non testato. - test_run_dry_run: assert su 'CLEAN' + 'SQL' separati nel testo normalizzato, senza assumere l'ancora cmd_run.py:NNNN (formato logger). - Test multi-year 4/4, dry-run 21/21, cli_path_contract 23/23.
Member
Author
Review follow-up (2026-08-02) — checklist impatto aggiornataIn risposta alla review, segnalo la correzione alla sezione "Impatto su contratti pubblici" del body: la PR tocca il path output delle mart multi-year (le tabelle con
Per completezza, la checklist aggiornata:
Downstream: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sintesi
Fix della validazione mart multi-year (
mart.tables[].years). Prima del fix, un candidate con tabelle mart multi-year non poteva completare il run: la validazione per-anno falliva (Missing required MART tables) e il passaggio multi-year non partiva mai. Inoltre letable_rulesdelle tabelle multi-year non venivano mai applicate.Contesto collegato
iva-regionale(CI rossa su PR dataset-incubator #763)mart.tables[].yearsè documentato inconfig-schema.md§"output multi-anno" (sostituto dicross_year) ma era inutilizzabileCosa cambia
Impatto
toolkit runper candidate con tabelle multi-yearDettaglio
Gap 1 —
mart/validate.py: validazione per-anno esclude le tabelle multi-yearrun_mart_validationesclude dallerequired_tablesper-anno le tabelle conyears(prodotte a livello dataset, non nel dir per-anno). Prima:Missing required MART tablesfalliva sempre il run quando esistevano tabelle multi-year inrequired_tables.Gap 2 —
mart/run.py: validazione multi-year applicatarun_mart_multi_yearora valida le tabelle prodotte convalidate_mart(applicatable_rules/required_tablesdelle tabelle conyears). Prima: nessuna validazione multi-year esisteva — le regole non venivano mai applicate. L'esito è registrato nel metadata (validation) e nel return (validation_passed/validation_errors).Gap 3 —
cli/cmd_run.py: solo multi-year non blocca il runQuando
has_single_year_martè False (tutte le tabelle multi-year), registra una validazione mart "skipped" (passed=True) per non far fallire il run per-anno._maybe_run_multi_year_martpropagavalidation_passed=Falsecome errore (rispettafail_on_error).Verifica
Test nuovi:
test_mart_only_multi_year— candidate con TUTTE le tabelleyears: run passa, output dataset-level esiste, validazione multi-year applicata (prima falliva)Verifica reale (dataset-incubator,
iva-regionalecon 1 tabella per-anno + 2 multi-year):metadata.validation.passed: True, 0 erroriSuite completa: 1222 passed. I 16 fallimenti sono pre-esistenti su main (fixture
project-examplemancante in ambiente locale), verificati indipendenti dal fix.Checklist