forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fco_diff.py
More file actions
75 lines (66 loc) · 2.64 KB
/
test_fco_diff.py
File metadata and controls
75 lines (66 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from feast.diff.FcoDiff import diff_between, tag_proto_objects_for_keep_delete_add
from feast.feature_view import FeatureView
from tests.utils.data_source_utils import prep_file_source
def test_tag_proto_objects_for_keep_delete_add(simple_dataset_1):
with prep_file_source(
df=simple_dataset_1, event_timestamp_column="ts_1"
) as file_source:
to_delete = FeatureView(
name="to_delete", entities=["id"], batch_source=file_source, ttl=None,
).to_proto()
unchanged_fv = FeatureView(
name="fv1", entities=["id"], batch_source=file_source, ttl=None,
).to_proto()
pre_changed = FeatureView(
name="fv2",
entities=["id"],
batch_source=file_source,
ttl=None,
tags={"when": "before"},
).to_proto()
post_changed = FeatureView(
name="fv2",
entities=["id"],
batch_source=file_source,
ttl=None,
tags={"when": "after"},
).to_proto()
to_add = FeatureView(
name="to_add", entities=["id"], batch_source=file_source, ttl=None,
).to_proto()
keep, delete, add = tag_proto_objects_for_keep_delete_add(
[unchanged_fv, pre_changed, to_delete], [unchanged_fv, post_changed, to_add]
)
assert len(list(keep)) == 2
assert unchanged_fv in keep
assert post_changed in keep
assert pre_changed not in keep
assert len(list(delete)) == 1
assert to_delete in delete
assert len(list(add)) == 1
assert to_add in add
def test_diff_between_feature_views(simple_dataset_1):
with prep_file_source(
df=simple_dataset_1, event_timestamp_column="ts_1"
) as file_source:
pre_changed = FeatureView(
name="fv2",
entities=["id"],
batch_source=file_source,
ttl=None,
tags={"when": "before"},
).to_proto()
post_changed = FeatureView(
name="fv2",
entities=["id"],
batch_source=file_source,
ttl=None,
tags={"when": "after"},
).to_proto()
fco_diffs = diff_between(pre_changed, pre_changed, "feature view")
assert len(fco_diffs.fco_property_diffs) == 0
fco_diffs = diff_between(pre_changed, post_changed, "feature view")
assert len(fco_diffs.fco_property_diffs) == 1
assert fco_diffs.fco_property_diffs[0].property_name == "tags"
assert fco_diffs.fco_property_diffs[0].val_existing == {"when": "before"}
assert fco_diffs.fco_property_diffs[0].val_declared == {"when": "after"}