Skip to content

Commit

Permalink
fix: datetime.fromisoformat for py<3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
helen-m-lin committed Aug 21, 2024
1 parent c10c167 commit 850e00c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/aind_data_transfer_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ class AirflowDagRunsRequestParameters(BaseModel):
def validate_min_execution_date(cls, execution_date_gte: str):
"""Validate the earliest submit date filter is within 2 weeks"""
min_execution_date = datetime.now(timezone.utc) - timedelta(weeks=2)
if datetime.fromisoformat(execution_date_gte) < min_execution_date:
# datetime.fromisoformat does not support Z in python < 3.11
date_to_check = execution_date_gte.replace("Z", "+00:00")
if datetime.fromisoformat(date_to_check) < min_execution_date:
raise ValueError(
"execution_date_gte must be within the last 2 weeks"
)
Expand Down

0 comments on commit 850e00c

Please sign in to comment.