diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index f1db20eb..08c9187c 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -33,3 +33,24 @@ jobs: uses: ./.github/workflows/test_python_lambda.yml with: path_to_lambda: lambdas/data-transfer + + validate-collections: + name: Validate collections + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Install poetry + run: pipx install poetry + - uses: actions/setup-python@v4 + with: + python-version: "3.8" # NOTE: Should match Lambda runtime specified in CDK code + cache: "poetry" + cache-dependency-path: | + poetry.lock + labmdas/build-stac/requirements**.txt + - name: Install requirements + run: | + poetry install + poetry add $(cat lambdas/build-stac/requirements**.txt ) + - name: Validate collections + run: scripts/validate_collections.py diff --git a/data/collections/caldor-fire-behavior.json b/data/collections/caldor-fire-behavior.json index bfa9b72b..231e40e8 100644 --- a/data/collections/caldor-fire-behavior.json +++ b/data/collections/caldor-fire-behavior.json @@ -8,10 +8,10 @@ "spatial":{ "bbox":[ [ - "-180", - "90", - "-90", - "180" + -180, + 90, + -90, + 180 ] ] }, diff --git a/data/collections/caldor-fire-burn-severity.json b/data/collections/caldor-fire-burn-severity.json index 3ace6b4a..e42c73e0 100644 --- a/data/collections/caldor-fire-burn-severity.json +++ b/data/collections/caldor-fire-burn-severity.json @@ -8,10 +8,10 @@ "spatial":{ "bbox":[ [ - "-180", - "90", - "-90", - "180" + -180, + 90, + -90, + 180 ] ] }, diff --git a/data/collections/ecco-surface-height-change.json b/data/collections/ecco-surface-height-change.json index 9634368e..73bfd1c2 100644 --- a/data/collections/ecco-surface-height-change.json +++ b/data/collections/ecco-surface-height-change.json @@ -8,10 +8,10 @@ "spatial":{ "bbox":[ [ - "-180", - "90", - "-90", - "180" + -180, + 90, + -90, + 180 ] ] }, diff --git a/data/collections/lis-tws-nonstationarity-index.json b/data/collections/lis-tws-nonstationarity-index.json index 03f3ea64..81693a5b 100644 --- a/data/collections/lis-tws-nonstationarity-index.json +++ b/data/collections/lis-tws-nonstationarity-index.json @@ -20,7 +20,7 @@ ] } }, - "license": "Creative Commons Zero (CC0-1.0)", + "license": "CC0-1.0", "description": "The global Terrestrial Water Storage (TWS) non-stationarity index integrates the trend, seasonal shifts, and variability change of TWS for the period of 2003 - 2020. TWS is derived by jointly assimilating the MODIS Leaf Area Index, the ESA CCI surface soil moisture, and the GSFC GRACE mascon-based TWS anomalies into the Noah-MP land surface model within the NASA Land Information System (LIS) at 10 km spatial resolution forced by the combination of MERRA2 and IMERG meteorological fields. The smaller the non-stationarity index is, the more the water cycle is under a non-stationary process. Glaciers and Greenland are excluded from the analysis.", "item_assets": { "cog_default": { diff --git a/data/collections/mtbs-burn-severity.json b/data/collections/mtbs-burn-severity.json index 0d0c38c0..10afa7f4 100644 --- a/data/collections/mtbs-burn-severity.json +++ b/data/collections/mtbs-burn-severity.json @@ -8,10 +8,10 @@ "spatial":{ "bbox":[ [ - "-126.49459612498832", - "24.0478678762251", - "-71.50752568733597", - "50.55916724898132" + -126.4945961, + 24.0478678, + -71.5075256, + 50.5591672 ] ] }, diff --git a/data/collections/nceo-africa-2017.json b/data/collections/nceo-africa-2017.json index e00409e8..c30a5c59 100644 --- a/data/collections/nceo-africa-2017.json +++ b/data/collections/nceo-africa-2017.json @@ -12,7 +12,7 @@ "title": "NCEO Africa Aboveground Woody Biomass 2017", "extent": { "spatial": { - " bbox": [[-18.2735295, -35.054059, 51.8642329, 37.7310386]] + "bbox": [[-18.2735295, -35.054059, 51.8642329, 37.7310386]] }, "temporal": { "interval": [["2017-01-01T00:00:00Z", "2018-01-01T00:00:00Z"]] diff --git a/scripts/validate_collections.py b/scripts/validate_collections.py new file mode 100644 index 00000000..927e71cb --- /dev/null +++ b/scripts/validate_collections.py @@ -0,0 +1,28 @@ +import sys +from pathlib import Path + +from pystac import Collection +from pystac.errors import STACValidationError + +root = Path(__file__).parents[1] +collections = root / "data" / "collections" + +errors = False +for path in collections.glob("*.json"): + try: + collection = Collection.from_file(str(path)) + except Exception as err: + errors = True + print( + f"ERROR [{path.name}]: could not read collection because {type(err)}: {err}" + ) + try: + collection.validate() + except STACValidationError as err: + errors = True + print( + f"VALIDATION [{path.name}]: {collection.id} is invalid because {err.source}" + ) + +if errors: + sys.exit(1)