Skip to content

Commit

Permalink
Change date parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
notoraptor committed Sep 23, 2024
1 parent 473d631 commit 8a13a95
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sarc/alerts/usage_alerts/cluster_response.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
from datetime import datetime, timedelta
from datetime import datetime, time, timedelta

from sarc.client.job import get_available_clusters
from sarc.config import MTL
from sarc.config import MTL, TZLOCAL

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -33,7 +33,10 @@ def check_cluster_response(time_interval: timedelta = timedelta(days=7)):
# Cluster's latest scraping date should be in `cluster.end_date`.
# NB: We assume cluster's `end_date` is stored as a date string,
# so we must first convert it to a datetime object.
cluster_end_date = datetime.fromisoformat(cluster.end_date).astimezone(MTL)
# `en_date` is parsed the same way as start/end parameters in `get_jobs()`.
cluster_end_date = datetime.combine(
datetime.strptime(cluster.end_date, "%Y-%m-%d"), time.min
).replace(tzinfo=TZLOCAL)
# Now we can check.
if cluster_end_date < oldest_allowed_date:
logger.warning(
Expand Down

0 comments on commit 8a13a95

Please sign in to comment.