Skip to content

Commit ed5e928

Browse files
feat: Add description, tags, owner fields to all feature view classes (#2440)
* Fix Entity docstring Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Adding description, tags, owner fields for all feature view classes Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Add docstrings for all feature view __init__ methods Signed-off-by: Felix Wang <wangfelix98@gmail.com>
1 parent 702ec49 commit ed5e928

8 files changed

+217
-54
lines changed

protos/feast/core/FeatureView.proto

+7
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ message FeatureView {
3535
FeatureViewMeta meta = 2;
3636
}
3737

38+
// Next available id: 12
3839
// TODO(adchia): refactor common fields from this and ODFV into separate metadata proto
3940
message FeatureViewSpec {
4041
// Name of the feature view. Must be unique. Not updated.
@@ -50,9 +51,15 @@ message FeatureViewSpec {
5051
// List of features specifications for each feature defined with this feature view.
5152
repeated FeatureSpecV2 features = 4;
5253

54+
// Description of the feature view.
55+
string description = 10;
56+
5357
// User defined metadata
5458
map<string,string> tags = 5;
5559

60+
// Owner of the feature view.
61+
string owner = 11;
62+
5663
// Features in this feature view can only be retrieved from online serving
5764
// younger than ttl. Ttl is measured as the duration of time between
5865
// the feature's event timestamp and when the feature is retrieved

protos/feast/core/OnDemandFeatureView.proto

+10
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ message OnDemandFeatureView {
3434
OnDemandFeatureViewMeta meta = 2;
3535
}
3636

37+
// Next available id: 9
3738
message OnDemandFeatureViewSpec {
3839
// Name of the feature view. Must be unique. Not updated.
3940
string name = 1;
@@ -48,6 +49,15 @@ message OnDemandFeatureViewSpec {
4849
map<string, OnDemandInput> inputs = 4;
4950

5051
UserDefinedFunction user_defined_function = 5;
52+
53+
// Description of the on demand feature view.
54+
string description = 6;
55+
56+
// User defined metadata.
57+
map<string,string> tags = 7;
58+
59+
// Owner of the on demand feature view.
60+
string owner = 8;
5161
}
5262

5363
message OnDemandFeatureViewMeta {

protos/feast/core/RequestFeatureView.proto

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ message RequestFeatureView {
2929
RequestFeatureViewSpec spec = 1;
3030
}
3131

32+
// Next available id: 7
3233
message RequestFeatureViewSpec {
3334
// Name of the feature view. Must be unique. Not updated.
3435
string name = 1;
@@ -38,4 +39,13 @@ message RequestFeatureViewSpec {
3839

3940
// Request data which contains the underlying data schema and list of associated features
4041
DataSource request_data_source = 3;
42+
43+
// Description of the request feature view.
44+
string description = 4;
45+
46+
// User defined metadata.
47+
map<string,string> tags = 5;
48+
49+
// Owner of the request feature view.
50+
string owner = 6;
4151
}

sdk/python/feast/base_feature_view.py

+59-19
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,75 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
import warnings
1514
from abc import ABC, abstractmethod
1615
from datetime import datetime
17-
from typing import List, Optional, Type
16+
from typing import Dict, List, Optional, Type
1817

1918
from google.protobuf.json_format import MessageToJson
2019
from proto import Message
2120

2221
from feast.feature import Feature
2322
from feast.feature_view_projection import FeatureViewProjection
2423

25-
warnings.simplefilter("once", DeprecationWarning)
26-
2724

2825
class BaseFeatureView(ABC):
29-
"""A FeatureView defines a logical grouping of features to be served."""
30-
26+
"""
27+
A BaseFeatureView defines a logical group of features.
28+
29+
Attributes:
30+
name: The unique name of the base feature view.
31+
features: The list of features defined as part of this base feature view.
32+
description: A human-readable description.
33+
tags: A dictionary of key-value pairs to store arbitrary metadata.
34+
owner: The owner of the base feature view, typically the email of the primary
35+
maintainer.
36+
projection: The feature view projection to be applied to this base feature view
37+
at retrieval time.
38+
created_timestamp (optional): The time when the base feature view was created.
39+
last_updated_timestamp (optional): The time when the base feature view was last
40+
updated.
41+
"""
42+
43+
name: str
44+
features: List[Feature]
45+
description: str
46+
tags: Dict[str, str]
47+
owner: str
48+
projection: FeatureViewProjection
3149
created_timestamp: Optional[datetime]
3250
last_updated_timestamp: Optional[datetime]
3351

3452
@abstractmethod
35-
def __init__(self, name: str, features: List[Feature]):
53+
def __init__(
54+
self,
55+
name: str,
56+
features: List[Feature],
57+
description: str = "",
58+
tags: Optional[Dict[str, str]] = None,
59+
owner: str = "",
60+
):
61+
"""
62+
Creates a BaseFeatureView object.
63+
64+
Args:
65+
name: The unique name of the base feature view.
66+
features: The list of features defined as part of this base feature view.
67+
description (optional): A human-readable description.
68+
tags (optional): A dictionary of key-value pairs to store arbitrary metadata.
69+
owner (optional): The owner of the base feature view, typically the email of the
70+
primary maintainer.
71+
72+
Raises:
73+
ValueError: A field mapping conflicts with an Entity or a Feature.
74+
"""
3675
self.name = name
3776
self.features = features
77+
self.description = description
78+
self.tags = tags or {}
79+
self.owner = owner
3880
self.projection = FeatureViewProjection.from_definition(self)
39-
self.created_timestamp: Optional[datetime] = None
40-
self.last_updated_timestamp: Optional[datetime] = None
81+
self.created_timestamp = None
82+
self.last_updated_timestamp = None
4183

4284
@property
4385
@abstractmethod
@@ -55,12 +97,7 @@ def from_proto(cls, feature_view_proto):
5597

5698
@abstractmethod
5799
def __copy__(self):
58-
"""
59-
Generates a deep copy of this feature view
60-
61-
Returns:
62-
A copy of this FeatureView
63-
"""
100+
"""Returns a deep copy of this base feature view."""
64101
pass
65102

66103
def __repr__(self):
@@ -92,10 +129,13 @@ def __eq__(self, other):
92129
"Comparisons should only involve BaseFeatureView class objects."
93130
)
94131

95-
if self.name != other.name:
96-
return False
97-
98-
if sorted(self.features) != sorted(other.features):
132+
if (
133+
self.name != other.name
134+
or sorted(self.features) != sorted(other.features)
135+
or self.description != other.description
136+
or self.tags != other.tags
137+
or self.owner != other.owner
138+
):
99139
return False
100140

101141
return True

sdk/python/feast/entity.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class Entity:
3636
with their associated features. If not specified, defaults to the name.
3737
description: A human-readable description.
3838
tags: A dictionary of key-value pairs to store arbitrary metadata.
39-
owner: The owner of the feature service, typically the email of the primary
40-
maintainer.
39+
owner: The owner of the entity, typically the email of the primary maintainer.
4140
created_timestamp: The time when the entity was created.
4241
last_updated_timestamp: The time when the entity was last updated.
4342
"""

sdk/python/feast/feature_view.py

+43-14
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,36 @@
5050

5151
class FeatureView(BaseFeatureView):
5252
"""
53-
A FeatureView defines a logical grouping of serveable features.
53+
A FeatureView defines a logical group of features.
5454
55-
Args:
56-
name: Name of the group of features.
57-
entities: The entities to which this group of features is associated.
55+
Attributes:
56+
name: The unique name of the feature view.
57+
entities: The list of entities with which this group of features is associated.
5858
ttl: The amount of time this group of features lives. A ttl of 0 indicates that
5959
this group of features lives forever. Note that large ttl's or a ttl of 0
6060
can result in extremely computationally intensive queries.
6161
batch_source: The batch source of data where this group of features is stored.
6262
stream_source (optional): The stream source of data where this group of features
6363
is stored.
64-
features (optional): The set of features defined as part of this FeatureView.
65-
tags (optional): A dictionary of key-value pairs used for organizing
66-
FeatureViews.
64+
features: The list of features defined as part of this feature view.
65+
online: A boolean indicating whether online retrieval is enabled for this feature
66+
view.
67+
description: A human-readable description.
68+
tags: A dictionary of key-value pairs to store arbitrary metadata.
69+
owner: The owner of the feature view, typically the email of the primary
70+
maintainer.
6771
"""
6872

73+
name: str
6974
entities: List[str]
70-
tags: Optional[Dict[str, str]]
7175
ttl: timedelta
72-
online: bool
7376
batch_source: DataSource
7477
stream_source: Optional[DataSource]
78+
features: List[Feature]
79+
online: bool
80+
description: str
81+
tags: Dict[str, str]
82+
owner: str
7583
materialization_intervals: List[Tuple[datetime, datetime]]
7684

7785
@log_exceptions
@@ -83,12 +91,31 @@ def __init__(
8391
batch_source: DataSource,
8492
stream_source: Optional[DataSource] = None,
8593
features: Optional[List[Feature]] = None,
86-
tags: Optional[Dict[str, str]] = None,
8794
online: bool = True,
95+
description: str = "",
96+
tags: Optional[Dict[str, str]] = None,
97+
owner: str = "",
8898
):
8999
"""
90100
Creates a FeatureView object.
91101
102+
Args:
103+
name: The unique name of the feature view.
104+
entities: The list of entities with which this group of features is associated.
105+
ttl: The amount of time this group of features lives. A ttl of 0 indicates that
106+
this group of features lives forever. Note that large ttl's or a ttl of 0
107+
can result in extremely computationally intensive queries.
108+
batch_source: The batch source of data where this group of features is stored.
109+
stream_source (optional): The stream source of data where this group of features
110+
is stored.
111+
features (optional): The list of features defined as part of this feature view.
112+
online (optional): A boolean indicating whether online retrieval is enabled for
113+
this feature view.
114+
description (optional): A human-readable description.
115+
tags (optional): A dictionary of key-value pairs to store arbitrary metadata.
116+
owner (optional): The owner of the feature view, typically the email of the
117+
primary maintainer.
118+
92119
Raises:
93120
ValueError: A field mapping conflicts with an Entity or a Feature.
94121
"""
@@ -106,9 +133,8 @@ def __init__(
106133
f"Entity or Feature name."
107134
)
108135

109-
super().__init__(name, _features)
136+
super().__init__(name, _features, description, tags, owner)
110137
self.entities = entities if entities else [DUMMY_ENTITY_NAME]
111-
self.tags = tags if tags is not None else {}
112138

113139
if isinstance(ttl, Duration):
114140
self.ttl = timedelta(seconds=int(ttl.seconds))
@@ -123,10 +149,9 @@ def __init__(
123149
else:
124150
self.ttl = ttl
125151

126-
self.online = online
127152
self.batch_source = batch_source
128153
self.stream_source = stream_source
129-
154+
self.online = online
130155
self.materialization_intervals = []
131156

132157
# Note: Python requires redefining hash in child classes that override __eq__
@@ -312,7 +337,9 @@ def to_proto(self) -> FeatureViewProto:
312337
name=self.name,
313338
entities=self.entities,
314339
features=[feature.to_proto() for feature in self.features],
340+
description=self.description,
315341
tags=self.tags,
342+
owner=self.owner,
316343
ttl=(ttl_duration if ttl_duration is not None else None),
317344
online=self.online,
318345
batch_source=batch_source_proto,
@@ -349,7 +376,9 @@ def from_proto(cls, feature_view_proto: FeatureViewProto):
349376
)
350377
for feature in feature_view_proto.spec.features
351378
],
379+
description=feature_view_proto.spec.description,
352380
tags=dict(feature_view_proto.spec.tags),
381+
owner=feature_view_proto.spec.owner,
353382
online=feature_view_proto.spec.online,
354383
ttl=(
355384
None

0 commit comments

Comments
 (0)