Skip to content

Rolling and expanding window alignment based on the user's time interval input - #2277

Merged
miratepuffin merged 26 commits into
masterfrom
fix/align-windows
Oct 15, 2025
Merged

miratepuffin merged 26 commits into
masterfrom
fix/align-windows

Conversation

@arienandalibi

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Added rolling_aligned() and expanding_aligned() functions which behave like rolling() and expanding() windows except that the start of each window is aligned with the smallest unit of time passed by the user. For example, if the interval is "1 month and 1 day", the first window will begin at the start of the day of the first time event. The non-aligned versions of these functions begin the window at the first time event. When used in Python, aligning is now the default and has to be disabled using align_start = False if desired.

Why are the changes needed?

It's more intuitive for windows to be aligned cleanly. If someone wants a rolling window over "1 year", they likely want it to start at the beginning of the calendar year and end at the end of the year.

Does this PR introduce any user-facing change? If yes is this documented?

The functions expanding() and rolling() now have a new option parameter called align_start, which allows users to disable the alignment (use the same functionality as before).

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'GraphQL Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 7fafdff Previous: f14de7d Ratio
addNode 19 req/s 1460 req/s 76.84

This comment was automatically generated by workflow using github-action-benchmark.

…e like expanding() and rolling() windows but are aligned at the start. They get aligned at the smallest unit of time passed as input.
…() functions. Added align_start flag in those functions as well. Added python tests for alignment of rolling and expanding windows, both for Python and GraphQL. Changed logic so alignment also happens on step if it is provided.
…e mismatched discrete/temporal intervals for window and step. Tests updated to reflect that.
…nt types, such as node, nodes, edge, edges, path_from_node, path_from_graph, and for mismatched window and step types.
… a step is not passed, then the step defaults to the window). Adjusted tests accordingly. Update window() documentation to not say start and end are optional

@ljeub-pometry ljeub-pometry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Some suggestions for the rust api
  • tests should check the end of the rolling as well and make sure it is sensible (they look only at the first 3 windows in a lot of cases right now)

Comment thread python/tests/test_base_install/test_graphdb/test_rolling_expanding_alignment.py Outdated
Comment thread raphtory-core/src/utils/time.rs Outdated
Comment thread raphtory-core/src/utils/time.rs Outdated
Comment thread raphtory-core/src/utils/time.rs Outdated
Comment thread raphtory/src/db/api/view/time.rs Outdated
Comment thread raphtory/src/db/api/view/time.rs
…indow can lead to entries being outside of all windows (before start and/or after end). Updated rolling/expanding tests to verify the last window as well (test boundaries). Added some tests for different step/window combinations.
github-actions Bot and others added 11 commits September 25, 2025 07:04
…ling_aligned()/expanding_aligned() now take an AlignmentUnit parameter for custom alignment.
…tional string alignment_unit parameter for custom alignment. If no alignment_unit is passed, aligns on the smallest unit like before. "unaligned" allows for no alignment.
…ptional enum alignment_unit parameter for custom alignment, like in Python. If no alignment_unit is passed, aligns on the smallest unit like before. "unaligned" allows for no alignment.
# Conflicts:
#	pometry-storage-private
#	raphtory/src/algorithms/motifs/temporal_rich_club_coefficient.rs
#	raphtory/src/db/api/view/time.rs
#	raphtory/src/db/graph/graph.rs
github-actions Bot and others added 5 commits October 8, 2025 00:48
…d (it previously did). If we do `g.layer("x").rolling("1 month")`, the first window will start aligned with the graph's first event, not the first event on layer "x" (even if the first window will be empty)
…f continuous addition. This fixes the previous bug caused by: Jan 31st + "1 month" = Feb 28th; if this happens on the window's end, all following windows will be on the 28th (instead of 29th, 30th, or 31st). This also used to happen for windows always ending on the 30th even if they should end on the 31st. Added and fixed tests for it as well.
@miratepuffin
miratepuffin marked this pull request as ready for review October 15, 2025 14:52
@miratepuffin
miratepuffin merged commit 08685ee into master Oct 15, 2025
6 checks passed
@miratepuffin
miratepuffin deleted the fix/align-windows branch October 15, 2025 14:54
@miratepuffin miratepuffin added this to the 0.16.3 milestone Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants