Skip to content

Commit

Permalink
fix: aggregations with offset
Browse files Browse the repository at this point in the history
  • Loading branch information
Mats E. Mollestad committed Nov 22, 2023
1 parent f6829ab commit 75e1d47
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
21 changes: 9 additions & 12 deletions aligned/local/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,22 @@ async def aggregate(request: RetrivalRequest, core_data: pl.LazyFrame) -> pl.Laz
raise ValueError('No time window spesificed.')

if over.window.every_interval:
sub = (
sorted_data.groupby_dynamic(
time_name,
every=over.window.every_interval,
period=over.window.time_window,
offset=over.window.offset_interval,
by=over.group_by_names,
)
.agg(exprs)
.with_columns(pl.col(time_name) + over.window.time_window)
)
sub = sorted_data.groupby_dynamic(
time_name,
every=over.window.every_interval,
period=over.window.time_window,
by=over.group_by_names,
).agg(exprs)
else:
sub = sorted_data.groupby_rolling(
time_name,
period=over.window.time_window,
offset=over.window.offset_interval,
by=over.group_by_names,
).agg(exprs)

if over.window.offset_interval:
sub = sub.with_columns(pl.col(time_name) - over.window.offset_interval)

if results is not None:
existing_result = results.collect()
new_aggregations = sub.collect()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aligned"
version = "0.0.45"
version = "0.0.46"
description = "A scalable feature store that makes it easy to align offline and online ML systems"
authors = ["Mats E. Mollestad <[email protected]>"]
license = "Apache-2.0"
Expand Down

0 comments on commit 75e1d47

Please sign in to comment.