Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/config-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 31 additions & 0 deletions tests/test_dataset_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions toolkit/core/dataset_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading