Skip to content

Commit 8ef2053

Browse files
authored
Add a description field the Feature Service class and proto (#1771)
* Add a description field the Feature Service class and proto Signed-off-by: Achal Shah <[email protected]> * proto3 Signed-off-by: Achal Shah <[email protected]> * tests Signed-off-by: Achal Shah <[email protected]> * make format Signed-off-by: Achal Shah <[email protected]>
1 parent 316aabb commit 8ef2053

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

protos/feast/core/FeatureService.proto

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ message FeatureServiceSpec {
2929

3030
// User defined metadata
3131
map<string,string> tags = 4;
32+
33+
// Description of the feature service.
34+
string description = 5;
3235
}
3336

3437

sdk/python/feast/feature_service.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class FeatureService:
3131
name: str
3232
features: List[FeatureViewProjection]
3333
tags: Dict[str, str]
34+
description: Optional[str] = None
3435
created_timestamp: Optional[datetime] = None
3536
last_updated_timestamp: Optional[datetime] = None
3637

@@ -39,6 +40,7 @@ def __init__(
3940
name: str,
4041
features: List[Union[FeatureTable, FeatureView, FeatureViewProjection]],
4142
tags: Optional[Dict[str, str]] = None,
43+
description: Optional[str] = None,
4244
):
4345
"""
4446
Creates a FeatureService object.
@@ -56,6 +58,7 @@ def __init__(
5658
else:
5759
raise ValueError(f"Unexpected type: {type(feature)}")
5860
self.tags = tags or {}
61+
self.description = description
5962
self.created_timestamp = None
6063
self.last_updated_timestamp = None
6164

@@ -97,6 +100,11 @@ def from_proto(feature_service_proto: FeatureServiceProto):
97100
for fp in feature_service_proto.spec.features
98101
],
99102
tags=dict(feature_service_proto.spec.tags),
103+
description=(
104+
feature_service_proto.spec.description
105+
if feature_service_proto.spec.description != ""
106+
else None
107+
),
100108
)
101109

102110
if feature_service_proto.meta.HasField("created_timestamp"):
@@ -137,6 +145,8 @@ def to_proto(self) -> FeatureServiceProto:
137145

138146
if self.tags:
139147
spec.tags.update(self.tags)
148+
if self.description:
149+
spec.description = self.description
140150

141151
feature_service_proto = FeatureServiceProto(spec=spec, meta=meta)
142152
return feature_service_proto
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from feast import FeatureService
2+
3+
4+
def test_feature_service_with_description():
5+
feature_service = FeatureService(
6+
name="my-feature-service", features=[], description="a clear description"
7+
)
8+
assert feature_service.to_proto().spec.description == "a clear description"
9+
10+
11+
def test_feature_service_without_description():
12+
feature_service = FeatureService(name="my-feature-service", features=[])
13+
#
14+
assert feature_service.to_proto().spec.description == ""

0 commit comments

Comments
 (0)