Files
astrape-oracle/scripts/debug/debug_duplicates.py
T
rpotter6298 9a4ee8e0cf Flatten to a single package directory
The checkout is now astrape/astrape-oracle, not astrape/astrape-oracle/<package>. The package
contents move to the repository root and pyproject maps the package name to
'.' via package-dir, with the subpackages listed explicitly.

The systemd units move out to /srv/astrape/deploy/systemd, outside every
repository, because they describe this deployment rather than any one
component.

Verified both install modes: editable, which is how the deployment runs, and
a plain wheel install, which is what the container build does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 15:05:17 +02:00

32 lines
1.1 KiB
Python

#!/usr/bin/env python3
"""Debug script to find duplicate target times in forecast data."""
from astrape_ems.classes.env import EnvLoader
from astrape_oracle.classes.weather.store import WeatherStore
from collections import defaultdict
EnvLoader().load()
store = WeatherStore.from_env()
dataset = store.load_display_dataset()
# Group by (target_at, horizon_hours) to find duplicates
by_key = defaultdict(list)
for point in dataset.forecast_points:
key = (point.target_at, point.horizon_hours)
by_key[key].append(point)
# Find duplicates
duplicates = {k: v for k, v in by_key.items() if len(v) > 1}
print(f"\nTotal forecast points: {len(dataset.forecast_points)}")
print(f"Unique (target_at, horizon) pairs: {len(by_key)}")
print(f"Duplicate (target_at, horizon) pairs: {len(duplicates)}")
if duplicates:
print("\nFirst 3 duplicates:")
for (target_at, horizon), points in list(duplicates.items())[:3]:
print(f"\n target_at={target_at}, horizon={horizon}h ({len(points)} points):")
for i, p in enumerate(points):
print(f" [{i}] issued_at={p.issued_at}, temp={p.temperature_c}, source={p.source}")