Metadata-Version: 2.4
Name: hestia_earth_validation
Version: 0.41.0
Summary: HESTIA Data Validation library
Home-page: https://gitlab.com/hestia-earth/hestia-data-validation
Author: Guillaume Royer
Author-email: guillaumeroyer.mail@gmail.com
License: MIT
Keywords: hestia,data,validation
Requires-Python: >=3
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: hestia-earth-schema>=39.0.0
Requires-Dist: hestia-earth-utils>=0.17.19
Provides-Extra: models
Requires-Dist: hestia-earth-models>=0.86.1; extra == "models"
Provides-Extra: spatial
Requires-Dist: hestia-earth-earth-engine>=0.6.0; extra == "spatial"
Provides-Extra: distribution
Requires-Dist: hestia-earth-distribution>=0.7.0; extra == "distribution"
Dynamic: author
Dynamic: author-email
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# HESTIA Data Validation

[![Pipeline Status](https://gitlab.com/hestia-earth/hestia-data-validation/badges/master/pipeline.svg)](https://gitlab.com/hestia-earth/hestia-data-validation/commits/master)
[![Coverage Report](https://gitlab.com/hestia-earth/hestia-data-validation/badges/master/coverage.svg)](https://gitlab.com/hestia-earth/hestia-data-validation/commits/master)
[![Documentation Status](https://readthedocs.org/projects/hestia-data-validation/badge/?version=latest)](https://hestia-data-validation.readthedocs.io/en/latest/?badge=latest)

## Install

```bash
pip install hestia_earth_validation
```

## Usage

```python
from hestia_earth.validation.preload_requests import enable_preload
from hestia_earth.validation import validate

# enable request preloading
enable_preload()
# for each node, this will return a list containing all the errors/warnings (empty list if no errors/warnings)
errors = validate(nodes)
```

Note: if you want to validate existing data (with `@type` and `@id` fields), please set the following environment variable:

```bash
VALIDATE_EXISTING_NODES=true
```

## Spatial validation

Some validations need geospatial data: whether a Site's coordinates fall inside the `country` or `region` it declares, how far outside they are, whether the region is small enough for the models to gap-fill, and whether the declared `siteType` matches the MODIS land cover there.

There are two ways to provide it, and either is enough:

```bash
# 1. the HESTIA Caching API, if it holds the land cover and GADM assets
VALIDATION_CACHING_API_URL=https://<host>/api
VALIDATION_CACHING_API_KEY=<token>

# 2. Earth Engine, which needs an account and credentials
pip install "hestia-earth-validation[spatial]"
```

The Caching API is preferred when it can answer, and anything it has no asset for still goes to Earth Engine — so the two combine rather than compete. `MODELS_CACHING_API_*` is read as a fallback for the variables above, which is what most deployments already set.

Set `VALIDATE_SPATIAL=false` to skip these validations entirely. Without either backend they are skipped anyway, with an error in the log: validating coordinates against data nobody can fetch would report every Site as being outside its own country.
