-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for hourly runs and reprocessing
- Loading branch information
Showing
12 changed files
with
252 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from datetime import datetime, timedelta | ||
from typing import Tuple | ||
|
||
|
||
def build_timestamps( | ||
start_at: datetime, end_at: datetime | ||
) -> list[Tuple[str, datetime]]: | ||
""" | ||
contruct a list of timestamps between start_at and end_at. | ||
They are constructed in such a way that we will have whole days expressed as | ||
YYYY-MM-DD, while hourly intervals will be expressed as YYYY-MM-DDTHH. | ||
For example given the range(2024-01-01T00 -> 2024-01-03T03) we will get: | ||
[ | ||
2024-01-01T01, | ||
2024-01-01T02, | ||
2024-01-01T03, | ||
... | ||
2024-01-02, | ||
2024-01-03T00, | ||
2024-01-03T01, | ||
2024-01-03T02, | ||
2024-01-03T02, | ||
] | ||
""" | ||
timestamps = [] | ||
current = start_at | ||
|
||
while current < end_at: | ||
if ( | ||
current.hour == 0 | ||
and current != start_at | ||
and current < end_at.replace(hour=0) | ||
): | ||
timestamps.append((current.strftime("%Y-%m-%d"), current)) | ||
current += timedelta(days=1) | ||
else: | ||
timestamps.append((current.strftime("%Y-%m-%dT%H"), current)) | ||
current += timedelta(hours=1) | ||
|
||
return timestamps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.