Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.

Commit

Permalink
fix: make collections valid
Browse files Browse the repository at this point in the history
Includes:

- A simple script to validate all collection files
- A new CI/CD step to run the validation script

There wasn't an obvious place to add the validation to a lambda test, so I make
it its own thing.
  • Loading branch information
gadomski committed Sep 19, 2023
1 parent 5b46fe4 commit 946db78
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 18 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions data/collections/caldor-fire-behavior.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"spatial":{
"bbox":[
[
"-180",
"90",
"-90",
"180"
-180,
90,
-90,
180
]
]
},
Expand Down
8 changes: 4 additions & 4 deletions data/collections/caldor-fire-burn-severity.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"spatial":{
"bbox":[
[
"-180",
"90",
"-90",
"180"
-180,
90,
-90,
180
]
]
},
Expand Down
8 changes: 4 additions & 4 deletions data/collections/ecco-surface-height-change.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"spatial":{
"bbox":[
[
"-180",
"90",
"-90",
"180"
-180,
90,
-90,
180
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion data/collections/lis-tws-nonstationarity-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
8 changes: 4 additions & 4 deletions data/collections/mtbs-burn-severity.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"spatial":{
"bbox":[
[
"-126.49459612498832",
"24.0478678762251",
"-71.50752568733597",
"50.55916724898132"
-126.4945961,
24.0478678,
-71.5075256,
50.5591672
]
]
},
Expand Down
2 changes: 1 addition & 1 deletion data/collections/nceo-africa-2017.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]]
Expand Down
28 changes: 28 additions & 0 deletions scripts/validate_collections.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 946db78

Please sign in to comment.