Skip to content

Commit 7b8b85f

Browse files
authored
Merge pull request #90 from Climate-Vision/merge/pr-50
fix: validate start_date <= end_date in PredictRequest (#50, rebased)
2 parents 921b6ca + d5ebcc3 commit 7b8b85f

6 files changed

Lines changed: 2391 additions & 5 deletions

File tree

src/climatevision/api/main.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,14 @@ class PredictRequest(BaseModel):
121121
kind: str = Field(default="demo")
122122
analysis_type: AnalysisType = Field(default="deforestation")
123123
bbox: Optional[list[float]] = None
124-
start_date: Optional[str] = None
125-
end_date: Optional[str] = None
124+
start_date: Optional[str] = Field(
125+
default=None,
126+
description="Start date in YYYY-MM-DD format. Must be earlier than end_date.",
127+
)
128+
end_date: Optional[str] = Field(
129+
default=None,
130+
description="End date in YYYY-MM-DD format. Must be later than start_date.",
131+
)
126132

127133
@field_validator("bbox")
128134
@classmethod
@@ -651,9 +657,6 @@ async def predict_json(
651657
org: dict[str, Any] = Depends(require_api_key),
652658
) -> dict[str, Any]:
653659
"""Run prediction using bounding box and date range."""
654-
if body.start_date and body.end_date and body.start_date > body.end_date:
655-
raise HTTPException(status_code=400, detail="start_date must be before end_date")
656-
657660
created_at = _utc_now_iso()
658661
bbox_json = json.dumps(body.bbox) if body.bbox else None
659662

team_docs/Francis_Umo_Role.pdf

10.6 KB
Binary file not shown.

team_docs/Olufemi_Taiwo_Role.pdf

11.4 KB
Binary file not shown.

team_docs/Victor_Mbachu_Role.pdf

14.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)