Skip to content

Commit befe6d3

Browse files
authored
Merge pull request #24 from Eppo-exp/emiel/add-type-property-to-metrics
Emiel/add type property to metrics
2 parents 54ab737 + 81a455a commit befe6d3

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2023 Eppo
3+
Copyright (c) 2023-2024 Eppo
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

eppo_metrics_sync/schema/eppo_metric_schema.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"description": "User-friendly description of the fact",
7272
"type": "string"
7373
},
74-
"desired_change" : {
74+
"desired_change": {
7575
"description": "Specify whether or not increases in the fact are desired",
7676
"enum": ["increase", "decrease"]
7777
}
@@ -124,6 +124,10 @@
124124
"description": "A user-friendly description of the fact",
125125
"type": "string"
126126
},
127+
"type": {
128+
"description": "The kind of metric to be calculated",
129+
"enum": ["simple", "ratio", "funnel", "percentile"]
130+
},
127131
"entity": {
128132
"description": "Must exactly match entity's name in Eppo UI",
129133
"type": "string"
@@ -146,7 +150,7 @@
146150
},
147151
"guardrail_cutoff": {
148152
"description": "If a metric is expected to increase, this value should be negative, to warn when the metric is decreasing by more than this value.",
149-
"type": "number"
153+
"type": ["number", "null"]
150154
},
151155
"numerator": {
152156
"description": "Specify how the numerator of this metric should be aggregated",

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='eppo_metrics_sync',
5-
version='0.1.0',
5+
version='0.1.1',
66
packages=find_packages(),
77
install_requires=[
88
'PyYAML', 'jsonschema', 'requests'

tests/test_validation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def test_valid_guardrail_cutoff_signs():
5454
eppo_metrics_sync = EppoMetricsSync(directory = None)
5555
eppo_metrics_sync.load_yaml(
5656
path = test_yaml_dir + "/duplicated_fact_property_names.yaml")
57-
57+
5858
with pytest.raises(ValueError, match = "Fact property names are not unique: device"):
5959
eppo_metrics_sync.validate()"""
6060

@@ -151,4 +151,4 @@ def test_first_value():
151151
def test_valid_yaml():
152152
eppo_metrics_sync = EppoMetricsSync(directory=None)
153153
eppo_metrics_sync.load_eppo_yaml(path='tests/yaml/valid/purchases.yaml')
154-
eppo_metrics_sync.validate()
154+
eppo_metrics_sync.validate()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
fact_sources:
2+
- name: upgrades_table
3+
sql: select * from upgrades
4+
timestamp_column: ts
5+
entities:
6+
- entity_name: user
7+
column: user_id
8+
facts:
9+
- name: upgrades
10+
metrics:
11+
- name: Total Upgrades to Paid Plan
12+
entity: User
13+
type: Nonexistent
14+
numerator:
15+
fact_name: upgrades
16+
operation: sum

tests/yaml/valid/purchases.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
fact_sources:
22
- name: Purchase
33
sql: |
4-
SELECT
4+
SELECT
55
events.*
66
FROM customer_db.onboarding.events as events
77
WHERE event_type = 'Revenue'
@@ -30,6 +30,7 @@ metrics:
3030
operation: distinct_entity
3131
- name: AOV
3232
entity: User
33+
type: ratio
3334
numerator:
3435
fact_name: Purchase
3536
operation: sum

0 commit comments

Comments
 (0)