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
21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: CI (continuous integration)

on:
pull_request:
push:
branches: [main, esgvoc_dev]

jobs:
check-all-filenames:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Check for duplicate term IDs
run: |
python _scripts/check-cv-entry-filenames.py
53 changes: 53 additions & 0 deletions _scripts/check-cv-entry-filenames.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
"""
Check for duplicate term IDs within each collection.

The id field references a universe term and does not have to match the
filename, but two files in the same collection must never share the
same id — that causes duplicate rows during esgvoc ingestion.
"""

import json
import os
import sys
from collections import defaultdict
from pathlib import Path


SKIP_DIRS = {".git", ".github", ".idea", ".venv", "_CVs", "_scripts"}


def main():
repo_root = Path(__file__).parents[1]

failing = []
for entry in sorted(os.scandir(repo_root), key=lambda e: e.name):
if not entry.is_dir() or entry.name in SKIP_DIRS or entry.name.startswith("."):
continue

ids_seen: dict[str, list[str]] = defaultdict(list)
for cv_file in sorted(Path(entry.path).glob("*.json")):
with open(cv_file) as fh:
content = json.load(fh)

if "id" not in content:
continue

ids_seen[content["id"]].append(str(cv_file))

for term_id, files in ids_seen.items():
if len(files) > 1:
failing.append(
f"{entry.name}: duplicate id '{term_id}' in {files}"
)

if failing:
print("Duplicate term IDs found:", file=sys.stderr)
for f in failing:
print(f" {f}", file=sys.stderr)
raise SystemExit(1)

print("No duplicate term IDs found.")


if __name__ == "__main__":
main()
5 changes: 0 additions & 5 deletions citation_url/url.json

This file was deleted.

5 changes: 0 additions & 5 deletions frequency/1hrCM.json

This file was deleted.

5 changes: 0 additions & 5 deletions frequency/1hrPt.json

This file was deleted.

5 changes: 0 additions & 5 deletions frequency/3hrPt.json

This file was deleted.

5 changes: 0 additions & 5 deletions frequency/6hrPt.json

This file was deleted.

5 changes: 0 additions & 5 deletions frequency/monC.json

This file was deleted.

5 changes: 0 additions & 5 deletions frequency/monPt.json

This file was deleted.

5 changes: 0 additions & 5 deletions frequency/subhrPt.json

This file was deleted.

5 changes: 0 additions & 5 deletions frequency/yrPt.json

This file was deleted.

5 changes: 0 additions & 5 deletions realm/atmosChem.json

This file was deleted.

5 changes: 0 additions & 5 deletions realm/landIce.json

This file was deleted.

5 changes: 0 additions & 5 deletions realm/ocnBgchem.json

This file was deleted.

5 changes: 0 additions & 5 deletions realm/seaIce.json

This file was deleted.

6 changes: 0 additions & 6 deletions tracking_id/obs4ref.json

This file was deleted.

3 changes: 2 additions & 1 deletion tracking_id/prefuuid.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"@context": "000_context.jsonld",
"id": "prefuuid",
"type": "tracking_id"
"type": "tracking_id",
"regex": "^hdl:21\\.14102/[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
}
5 changes: 0 additions & 5 deletions variable_id/baresoilFrac.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/burntFractionAll.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/c3PftFrac.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/c4PftFrac.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/cCwd.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/cLeaf.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/cLitter.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/cLitterAbove.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/cLitterBelow.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/cProduct.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/cRoot.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/cSoilFast.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/cSoilMedium.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/cSoilSlow.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/cVeg.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/ch4Clim.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/ch4globalClim.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/co2Clim.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/co2massClim.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/cropFrac.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/fFire.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/fGrazing.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/fHarvest.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/fLitterSoil.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/fVegLitter.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/fVegSoil.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/grassFrac.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/landCoverFrac.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/n2oClim.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/n2oglobalClim.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/nppLeaf.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/nppRoot.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/nppWood.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/o3Clim.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/pastureFrac.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/rGrowth.json

This file was deleted.

5 changes: 0 additions & 5 deletions variable_id/rMaint.json

This file was deleted.

Loading
Loading