Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add first_value and last_value aggregations and allow winsorization. #20

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eppo_metrics_sync/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ def aggregation_is_valid(aggregation):
error_message = []

if aggregation['operation'] not in ['sum', 'count', 'count_distinct', 'distinct_entity', 'threshold', 'retention',
'conversion']:
'conversion', 'last_value', 'first_value']:
error_message.append(
'Invalid aggregation operation: ' + aggregation['operation']
)

# can only winsorize sum or count metrics
if aggregation['operation'] not in ['sum', 'count']:
if aggregation['operation'] not in ['sum', 'count', 'last_value', 'first_value']:
if [name for name in winsorization_parameters if name in aggregation]:
error_message.append(
'Cannot winsorize a metric with operation ' + aggregation['operation']
Expand Down
8 changes: 8 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,11 @@ def test_count_distinct():

res = aggregation_is_valid(test_agg)
assert res == None

def test_last_value():
res = aggregation_is_valid({'operation': 'last_value'})
assert res == None

def test_first_value():
res = aggregation_is_valid({'operation': 'first_value'})
assert res == None
Loading