Skip to content

Commit

Permalink
validate the resulting STAC item
Browse files Browse the repository at this point in the history
  • Loading branch information
dchandan committed Feb 21, 2024
1 parent 1e83327 commit 246e663
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
from typing import Any, MutableMapping, NoReturn, Optional, Union

from pystac import STACValidationError
from pystac.extensions.datacube import DatacubeExtension
from requests.sessions import Session

Expand Down Expand Up @@ -75,6 +76,11 @@ def create_stac_item(
except Exception as e:
raise Exception("Failed to add THREDDS extension") from e

try:
item.validate()
except STACValidationError:
raise Exception("Failed to validate STAC item") from e

# print(json.dumps(item.to_dict()))
return json.loads(json.dumps(item.to_dict()))

Expand Down

0 comments on commit 246e663

Please sign in to comment.