-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathtest_feature_service.py
More file actions
74 lines (62 loc) · 2.35 KB
/
test_feature_service.py
File metadata and controls
74 lines (62 loc) · 2.35 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
from feast.feature_service import FeatureService
from feast.feature_view import FeatureView
from feast.field import Field
from feast.infra.offline_stores.file_source import FileSource
from feast.types import Float32
from tests.utils.test_wrappers import no_warnings
def test_feature_service_with_description():
feature_service = FeatureService(
name="my-feature-service", features=[], description="a clear description"
)
assert feature_service.to_proto().spec.description == "a clear description"
def test_feature_service_without_description():
feature_service = FeatureService(name="my-feature-service", features=[])
assert feature_service.to_proto().spec.description == ""
def test_hash():
file_source = FileSource(name="my-file-source", path="test.parquet")
feature_view = FeatureView(
name="my-feature-view",
entities=[],
schema=[
Field(name="feature1", dtype=Float32),
Field(name="feature2", dtype=Float32),
],
source=file_source,
)
feature_service_1 = FeatureService(
name="my-feature-service", features=[feature_view[["feature1", "feature2"]]]
)
feature_service_2 = FeatureService(
name="my-feature-service", features=[feature_view[["feature1", "feature2"]]]
)
feature_service_3 = FeatureService(
name="my-feature-service", features=[feature_view[["feature1"]]]
)
feature_service_4 = FeatureService(
name="my-feature-service",
features=[feature_view[["feature1"]]],
description="test",
)
s1 = {feature_service_1, feature_service_2}
assert len(s1) == 1
s2 = {feature_service_1, feature_service_3}
assert len(s2) == 2
s3 = {feature_service_3, feature_service_4}
assert len(s3) == 2
s4 = {feature_service_1, feature_service_2, feature_service_3, feature_service_4}
assert len(s4) == 3
@no_warnings
def test_feature_view_kw_args_normal():
file_source = FileSource(name="my-file-source", path="test.parquet")
feature_view = FeatureView(
name="my-feature-view",
entities=[],
schema=[
Field(name="feature1", dtype=Float32),
Field(name="feature2", dtype=Float32),
],
source=file_source,
)
_ = FeatureService(
name="my-feature-service", features=[feature_view[["feature1", "feature2"]]]
)