diff --git a/docs/config-schema.md b/docs/config-schema.md index 214b9cd..2b88536 100644 --- a/docs/config-schema.md +++ b/docs/config-schema.md @@ -27,6 +27,12 @@ I path relativi sono sempre risolti rispetto alla directory che contiene `datase | `dataset.years` | `list[int]` | nessuno | | `dataset.tags` | `list[string]` | `[]` | | `dataset.category` | `string \| null` | `null` | +| `dataset.time_coverage` | `{start_year: int, end_year: int} \| null` | `null` | + +`time_coverage` dichiara l'intervallo temporale del contenuto (non degli anni di +run). Esposto dal `dataset_loader` (manifest) e dal layer tool per la +catalogazione; usato dai candidate per serie storiche (es. `ga-sentenze`: +2023-2026). Opzionale ma raccomandato per serie storiche. ## raw diff --git a/tests/test_dataset_loader.py b/tests/test_dataset_loader.py index ffa0122..18d2c95 100644 --- a/tests/test_dataset_loader.py +++ b/tests/test_dataset_loader.py @@ -284,6 +284,37 @@ def test_warns_missing_source_id(self, tmp_path: Path) -> None: assert result["ok"] is True assert any("source_id" in w for w in result["warnings"]) + def test_warns_missing_tags_and_category(self, tmp_path: Path) -> None: + _write_dataset( + tmp_path, + { + "dataset": {"name": "test", "years": [2023], "source_id": "openga"}, + "raw": {"sources": [{"name": "src1"}]}, + }, + ) + result = validate_config(tmp_path) + assert result["ok"] is True + assert any("tags" in w for w in result["warnings"]) + assert any("category" in w for w in result["warnings"]) + + def test_no_warn_when_tags_category_present(self, tmp_path: Path) -> None: + _write_dataset( + tmp_path, + { + "dataset": { + "name": "test", + "years": [2023], + "source_id": "openga", + "tags": ["giustizia"], + "category": "giustizia", + }, + "raw": {"sources": [{"name": "src1"}]}, + }, + ) + result = validate_config(tmp_path) + assert result["ok"] is True + assert not any("tags" in w or "category" in w for w in result["warnings"]) + def test_invalid_yaml(self, tmp_path: Path) -> None: (tmp_path / "dataset.yml").write_text("invalid: [") result = validate_config(tmp_path) diff --git a/toolkit/core/dataset_loader.py b/toolkit/core/dataset_loader.py index 342fb14..dd5bbea 100644 --- a/toolkit/core/dataset_loader.py +++ b/toolkit/core/dataset_loader.py @@ -138,6 +138,15 @@ def validate_config(path: str | Path) -> dict[str, Any]: if sources and not manifest.get("source_id"): warnings.append("'dataset.source_id' non impostato (utile per catalogazione)") + if not manifest.get("tags"): + warnings.append( + "'dataset.tags' non impostato (standard candidate: lista kebab-case descrittiva)" + ) + if not manifest.get("category"): + warnings.append( + "'dataset.category' non impostato (standard candidate: tema — vedi docs/candidate-standard.md)" + ) + return { "ok": len(errors) == 0, "errors": errors,