Skip to content

Commit 893925b

Browse files
authored
Fix execution report heartbeat globs (#70)
1 parent 2713c1d commit 893925b

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

scripts/execution_report_heartbeat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ def _month_segments(start: dt.datetime, end: dt.datetime) -> list[str]:
6060
cursor = dt.datetime(start.year, start.month, 1, tzinfo=dt.timezone.utc)
6161
end_cursor = dt.datetime(end.year, end.month, 1, tzinfo=dt.timezone.utc)
6262
while cursor <= end_cursor:
63-
months.append(f"{cursor.year:04d}-{cursor.month:02d}")
63+
month = f"{cursor.year:04d}-{cursor.month:02d}"
64+
months.append(month)
65+
months.append(month.replace("-", "_"))
6466
if cursor.month == 12:
6567
cursor = dt.datetime(cursor.year + 1, 1, 1, tzinfo=dt.timezone.utc)
6668
else:
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from __future__ import annotations
2+
3+
import datetime as dt
4+
5+
from scripts import execution_report_heartbeat as heartbeat
6+
7+
8+
def test_report_globs_include_sanitized_month_segments(monkeypatch):
9+
monkeypatch.delenv("RUNTIME_HEARTBEAT_GCS_GLOBS", raising=False)
10+
monkeypatch.delenv("EXECUTION_REPORT_GCS_URI", raising=False)
11+
monkeypatch.delenv("RUNTIME_HEARTBEAT_GCS_URIS", raising=False)
12+
monkeypatch.delenv("RUNTIME_HEARTBEAT_REPORT_PLATFORM", raising=False)
13+
monkeypatch.setenv("FIRSTRADE_GCS_STATE_BUCKET", "runtime-state")
14+
monkeypatch.setenv("FIRSTRADE_STATE_PREFIX", "firstrade-platform")
15+
16+
globs = heartbeat._report_globs(
17+
dt.datetime(2026, 5, 31, tzinfo=dt.timezone.utc),
18+
dt.datetime(2026, 6, 1, tzinfo=dt.timezone.utc),
19+
)
20+
21+
assert globs == [
22+
"gs://runtime-state/firstrade-platform/strategy-runs/**/2026-05/*.json",
23+
"gs://runtime-state/firstrade-platform/strategy-runs/**/2026_05/*.json",
24+
"gs://runtime-state/firstrade-platform/strategy-runs/**/2026-06/*.json",
25+
"gs://runtime-state/firstrade-platform/strategy-runs/**/2026_06/*.json",
26+
]

0 commit comments

Comments
 (0)