feat: add DB-backed iter_db_snapshots utility to slice normalized tra…#104
Merged
gelluisaac merged 2 commits intoTraqora:mainfrom Mar 27, 2026
Merged
Conversation
…nsactions into discrete time-windowed graph snapshots for training
|
@soma-enyi Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #68
Problem
Training temporal GNN models requires the dataset to be sliced into discrete, ordered graph snapshots — one per time
window (t_0 to t_now). There was no utility to do this from the database; callers had to manually write SQLAlchemy
queries, handle timezone normalization, and reconstruct graph structures themselves.
Changes
astroml/features/graph/snapshot.py
Added two new components:
SnapshotWindow dataclass
A frozen dataclass representing a single time slice, carrying everything a training loop needs:
iter_db_snapshots() generator
Queries normalized_transactions and yields SnapshotWindow instances in chronological order from t0 to t_now.
Key behaviours:
t_0 … t_now range with no manual configuration
Usage
python
from astroml.features.graph.snapshot import iter_db_snapshots
for snap in iter_db_snapshots(window="7d", t0=t0, t_now=t_now):
print(f"[{snap.index}] {snap.start} → {snap.end}: {len(snap.nodes)} nodes, {len(snap.edges)} edges")
# feed snap.edges / snap.nodes into your GNN pipeline
Rolling windows:
python
7-day window sliding forward 1 day at a time
for snap in iter_db_snapshots(window="7d", step="1d"):
...
Related
Closes #[68] —Build a utility to slice the database into discrete time-windowed snapshots (e.g., t0 to t_now) for
training_