Spaces:
Sleeping
Sleeping
Download api/models.py from GeoOrg13/flood-vulnerability: direct link, hf CLI and curl.
- Browser
- Download file 1 kB
-
https://huggingface.co/spaces/GeoOrg13/flood-vulnerability/resolve/main/api/models.py
- Command line
-
hf download hf://spaces/GeoOrg13/flood-vulnerability/api/models.py
-
curl -L -o models.py https://huggingface.co/spaces/GeoOrg13/flood-vulnerability/resolve/main/api/models.py
1 kB
| """ | |
| Pydantic models for API request/response validation | |
| """ | |
| from pydantic import BaseModel, field_validator | |
| from typing import Optional | |
| class SingleAssessment(BaseModel): | |
| """Model for single location vulnerability assessment request""" | |
| latitude: float | |
| longitude: float | |
| height: Optional[float] = 0.0 | |
| basement: Optional[float] = 0.0 | |
| def check_lat(cls, v: float) -> float: | |
| if not -90 <= v <= 90: | |
| raise ValueError('Latitude must be between -90 and 90') | |
| return v | |
| def check_lon(cls, v: float) -> float: | |
| if not -180 <= v <= 180: | |
| raise ValueError('Longitude must be between -180 and 180') | |
| return v | |
| def check_basement(cls, v: float) -> float: | |
| if v > 0: | |
| raise ValueError('Basement height must be 0 or negative (e.g., -1, -2, -3)') | |
| return v | |