Skip to content

Commit 66c4338

Browse files
chore: Delete unused code in entity (feast-dev#3008)
* Delete unused parameters from entity Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix tests Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix Makefile Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Make `name` parameter required Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix test Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix docs Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix go test Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fixes Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix Makefile Signed-off-by: Felix Wang <wangfelix98@gmail.com>
1 parent ce26d8b commit 66c4338

File tree

14 files changed

+75
-158
lines changed

14 files changed

+75
-158
lines changed

docs/getting-started/concepts/feature-view.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,17 @@ It is suggested that you dynamically specify the new FeatureView name using `.wi
7474
{% tabs %}
7575
{% tab title="location_stats_feature_view.py" %}
7676
```python
77-
from feast import BigQuerySource, Entity, FeatureView, Field, ValueType
78-
from feast.types import Int32
77+
from feast import BigQuerySource, Entity, FeatureView, Field
78+
from feast.types import Int32, Int64
7979

80-
location = Entity(name="location", join_keys=["location_id"], value_type=ValueType.INT64)
80+
location = Entity(name="location", join_keys=["location_id"])
8181

8282
location_stats_fv= FeatureView(
8383
name="location_stats",
8484
entities=["location"],
8585
schema=[
86-
Field(name="temperature", dtype=Int32)
86+
Field(name="temperature", dtype=Int32),
87+
Field(name="location_id", dtype=Int64),
8788
],
8889
source=BigQuerySource(
8990
table="feast-oss.demo_data.location_stats"

docs/getting-started/quickstart.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ online_store:
8282

8383
from datetime import timedelta
8484

85-
from feast import Entity, FeatureService, FeatureView, Field, FileSource, ValueType
85+
from feast import Entity, FeatureService, FeatureView, Field, FileSource
8686
from feast.types import Float32, Int64
8787

8888
# Read data from parquet files. Parquet is convenient for local development mode. For
@@ -98,7 +98,7 @@ driver_hourly_stats = FileSource(
9898
# fetch features.
9999
# Entity has a name used for later reference (in a feature view, eg)
100100
# and join_key to identify physical field name used in storages
101-
driver = Entity(name="driver", value_type=ValueType.INT64, join_keys=["driver_id"], description="driver id",)
101+
driver = Entity(name="driver", join_keys=["driver_id"], description="driver id",)
102102

103103
# Our parquet files contain sample data that includes a driver_id column, timestamps and
104104
# three feature column. Here we define a Feature View that will allow us to serve this
@@ -111,6 +111,7 @@ driver_hourly_stats_view = FeatureView(
111111
Field(name="conv_rate", dtype=Float32),
112112
Field(name="acc_rate", dtype=Float32),
113113
Field(name="avg_daily_trips", dtype=Int64),
114+
Field(name="driver_id", dtype=Int64),
114115
],
115116
online=True,
116117
source=driver_hourly_stats,
@@ -165,7 +166,7 @@ feast apply
165166

166167
from datetime import timedelta
167168

168-
from feast import Entity, FeatureView, Field, FileSource, ValueType
169+
from feast import Entity, FeatureView, Field, FileSource
169170
from feast.types import Float32, Int64
170171

171172
# Read data from parquet files. Parquet is convenient for local development mode. For
@@ -181,7 +182,7 @@ driver_hourly_stats = FileSource(
181182
# fetch features.
182183
# Entity has a name used for later reference (in a feature view, eg)
183184
# and join_key to identify physical field name used in storages
184-
driver = Entity(name="driver", value_type=ValueType.INT64, join_keys=["driver_id"], description="driver id",)
185+
driver = Entity(name="driver", join_keys=["driver_id"], description="driver id",)
185186

186187
# Our parquet files contain sample data that includes a driver_id column, timestamps and
187188
# three feature column. Here we define a Feature View that will allow us to serve this
@@ -194,6 +195,7 @@ driver_hourly_stats_view = FeatureView(
194195
Field(name="conv_rate", dtype=Float32),
195196
Field(name="acc_rate", dtype=Float32),
196197
Field(name="avg_daily_trips", dtype=Int64),
198+
Field(name="driver_id", dtype=Int64),
197199
],
198200
online=True,
199201
source=driver_hourly_stats,

docs/reference/feature-repository.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ A feature repository can also contain one or more Python files that contain feat
8989
```python
9090
from datetime import timedelta
9191
92-
from feast import BigQuerySource, Entity, Feature, FeatureView, Field, ValueType
93-
from feast.types import Float32, String
92+
from feast import BigQuerySource, Entity, Feature, FeatureView, Field
93+
from feast.types import Float32, Int64, String
9494
9595
driver_locations_source = BigQuerySource(
9696
table="rh_prod.ride_hailing_co.drivers",
@@ -100,7 +100,6 @@ driver_locations_source = BigQuerySource(
100100
101101
driver = Entity(
102102
name="driver",
103-
value_type=ValueType.INT64,
104103
description="driver id",
105104
)
106105
@@ -111,6 +110,7 @@ driver_locations = FeatureView(
111110
schema=[
112111
Field(name="lat", dtype=Float32),
113112
Field(name="lon", dtype=String),
113+
Field(name="driver", dtype=Int64),
114114
],
115115
source=driver_locations_source,
116116
)

docs/reference/feature-repository/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ A feature repository can also contain one or more Python files that contain feat
9494
```python
9595
from datetime import timedelta
9696
97-
from feast import BigQuerySource, Entity, Feature, FeatureView, Field, ValueType
98-
from feast.types import Float32, String
97+
from feast import BigQuerySource, Entity, Feature, FeatureView, Field
98+
from feast.types import Float32, Int64, String
9999
100100
driver_locations_source = BigQuerySource(
101101
table_ref="rh_prod.ride_hailing_co.drivers",
@@ -105,7 +105,6 @@ driver_locations_source = BigQuerySource(
105105
106106
driver = Entity(
107107
name="driver",
108-
value_type=ValueType.INT64,
109108
description="driver id",
110109
)
111110
@@ -116,6 +115,7 @@ driver_locations = FeatureView(
116115
schema=[
117116
Field(name="lat", dtype=Float32),
118117
Field(name="lon", dtype=String),
118+
Field(name="driver", dtype=Int64),
119119
],
120120
source=driver_locations_source,
121121
)

go/internal/test/feature_repo/example.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
from google.protobuf.duration_pb2 import Duration
44

5-
from feast import Entity, Feature, FeatureView, FileSource, ValueType, FeatureService
5+
from feast import Entity, Feature, FeatureView, Field, FileSource, FeatureService
66
from feast.feature_logging import LoggingConfig
77
from feast.infra.offline_stores.file_source import FileLoggingDestination
8+
from feast.types import Float32, Int64
89

910
# Read data from parquet files. Parquet is convenient for local development mode. For
1011
# production, you can use your favorite DWH, such as BigQuery. See Feast documentation
@@ -17,19 +18,19 @@
1718

1819
# Define an entity for the driver. You can think of entity as a primary key used to
1920
# fetch features.
20-
driver = Entity(name="driver_id", value_type=ValueType.INT64, description="driver id",)
21+
driver = Entity(name="driver_id", description="driver id")
2122

2223
# Our parquet files contain sample data that includes a driver_id column, timestamps and
2324
# three feature column. Here we define a Feature View that will allow us to serve this
2425
# data to our model online.
2526
driver_hourly_stats_view = FeatureView(
2627
name="driver_hourly_stats",
27-
entities=["driver_id"],
28+
entities=[driver],
2829
ttl=Duration(seconds=86400 * 365 * 10),
29-
features=[
30-
Feature(name="conv_rate", dtype=ValueType.FLOAT),
31-
Feature(name="acc_rate", dtype=ValueType.FLOAT),
32-
Feature(name="avg_daily_trips", dtype=ValueType.INT64),
30+
schema=[
31+
Field(name="conv_rate", dtype=Float32),
32+
Field(name="acc_rate", dtype=Float32),
33+
Field(name="avg_daily_trips", dtype=Int64),
3334
],
3435
online=True,
3536
batch_source=driver_hourly_stats,

java/serving/src/test/resources/docker-compose/feast10/definitions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def transformed_conv_rate(features_df: pd.DataFrame) -> pd.DataFrame:
7171
path="benchmark_data.parquet", timestamp_field="event_timestamp",
7272
)
7373

74-
entity = Entity(name="entity", value_type=ValueType.STRING,)
74+
entity = Entity(name="entity")
7575

7676
benchmark_feature_views = [
7777
FeatureView(

sdk/python/feast/entity.py

Lines changed: 22 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
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 datetime import datetime
1615
from typing import Dict, List, Optional
1716

@@ -33,7 +32,10 @@ class Entity:
3332
3433
Attributes:
3534
name: The unique name of the entity.
36-
value_type (deprecated): The type of the entity, such as string or float.
35+
value_type: The type of the entity, such as string or float.
36+
join_keys: A list of properties that uniquely identifies different entities within the
37+
collection. This currently only supports a list of size one, but is intended to
38+
eventually support multiple join keys.
3739
join_key: A property that uniquely identifies different entities within the
3840
collection. The join_key property is typically used for joining entities
3941
with their associated features. If not specified, defaults to the name.
@@ -42,108 +44,62 @@ class Entity:
4244
owner: The owner of the entity, typically the email of the primary maintainer.
4345
created_timestamp: The time when the entity was created.
4446
last_updated_timestamp: The time when the entity was last updated.
45-
join_keys: A list of properties that uniquely identifies different entities within the
46-
collection. This is meant to replace the `join_key` parameter, but currently only
47-
supports a list of size one.
4847
"""
4948

5049
name: str
5150
value_type: ValueType
51+
join_keys: List[str]
5252
join_key: str
5353
description: str
5454
tags: Dict[str, str]
5555
owner: str
5656
created_timestamp: Optional[datetime]
5757
last_updated_timestamp: Optional[datetime]
58-
join_keys: List[str]
5958

6059
@log_exceptions
6160
def __init__(
6261
self,
63-
*args,
64-
name: Optional[str] = None,
65-
value_type: Optional[ValueType] = None,
62+
*,
63+
name: str,
64+
join_keys: Optional[List[str]] = None,
6665
description: str = "",
67-
join_key: Optional[str] = None,
6866
tags: Optional[Dict[str, str]] = None,
6967
owner: str = "",
70-
join_keys: Optional[List[str]] = None,
7168
):
7269
"""
7370
Creates an Entity object.
7471
7572
Args:
7673
name: The unique name of the entity.
77-
value_type (deprecated): The type of the entity, such as string or float.
78-
description: A human-readable description.
79-
join_key (deprecated): A property that uniquely identifies different entities within the
80-
collection. The join_key property is typically used for joining entities
81-
with their associated features. If not specified, defaults to the name.
82-
tags: A dictionary of key-value pairs to store arbitrary metadata.
83-
owner: The owner of the entity, typically the email of the primary maintainer.
84-
join_keys: A list of properties that uniquely identifies different entities within the
85-
collection. This is meant to replace the `join_key` parameter, but currently only
86-
supports a list of size one.
74+
join_keys (optional): A list of properties that uniquely identifies different entities
75+
within the collection. This currently only supports a list of size one, but is
76+
intended to eventually support multiple join keys.
77+
description (optional): A human-readable description.
78+
tags (optional): A dictionary of key-value pairs to store arbitrary metadata.
79+
owner (optional): The owner of the entity, typically the email of the primary maintainer.
8780
8881
Raises:
8982
ValueError: Parameters are specified incorrectly.
9083
"""
91-
if len(args) == 1:
92-
warnings.warn(
93-
(
94-
"Entity name should be specified as a keyword argument instead of a positional arg."
95-
"Feast 0.24+ will not support positional arguments to construct Entities"
96-
),
97-
DeprecationWarning,
98-
)
99-
if len(args) > 1:
100-
raise ValueError(
101-
"All arguments to construct an entity should be specified as keyword arguments only"
102-
)
103-
104-
self.name = args[0] if len(args) > 0 else name
105-
106-
if not self.name:
107-
raise ValueError("Name needs to be specified")
108-
109-
if value_type:
110-
warnings.warn(
111-
(
112-
"The `value_type` parameter is being deprecated. Instead, the type of an entity "
113-
"should be specified as a Field in the schema of a feature view. Feast 0.24 and "
114-
"onwards will not support the `value_type` parameter. The `entities` parameter of "
115-
"feature views should also be changed to a List[Entity] instead of a List[str]; if "
116-
"this is not done, entity columns will be mistakenly interpreted as feature columns."
117-
),
118-
DeprecationWarning,
119-
)
120-
self.value_type = value_type or ValueType.UNKNOWN
84+
self.name = name
85+
self.value_type = ValueType.UNKNOWN
12186

12287
# For now, both the `join_key` and `join_keys` attributes are set correctly,
12388
# so both are usable.
124-
# TODO(felixwang9817): Remove the usage of `join_key` throughout the codebase
125-
# when the usage of `join_key` as a parameter is removed.
126-
if join_key:
127-
warnings.warn(
128-
(
129-
"The `join_key` parameter is being deprecated in favor of the `join_keys` parameter. "
130-
"Please switch from using `join_key` to `join_keys`. Feast 0.24 and onwards will not "
131-
"support the `join_key` parameter."
132-
),
133-
DeprecationWarning,
134-
)
135-
self.join_keys = join_keys or []
89+
# TODO(felixwang9817): Fully remove the usage of `join_key` throughout the codebase,
90+
# at which point the `join_key` attribute no longer needs to be set.
13691
if join_keys and len(join_keys) > 1:
13792
raise ValueError(
13893
"An entity may only have single join key. "
13994
"Multiple join keys will be supported in the future."
14095
)
141-
if join_keys and len(join_keys) == 1:
96+
elif join_keys and len(join_keys) == 1:
97+
self.join_keys = join_keys
14298
self.join_key = join_keys[0]
14399
else:
144-
self.join_key = join_key if join_key else self.name
145-
if not self.join_keys:
100+
self.join_key = self.name
146101
self.join_keys = [self.join_key]
102+
147103
self.description = description
148104
self.tags = tags if tags is not None else {}
149105
self.owner = owner

sdk/python/tests/example_repos/example_feature_repo_version_0_19.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414

1515
driver = Entity(
1616
name="driver_id",
17-
value_type=ValueType.INT64,
1817
description="driver id",
19-
join_key="driver_id", # Changed to `join_keys` in 0.20
18+
join_keys=["driver_id"], # Changed to `join_keys` in 0.20
2019
)
2120

2221

sdk/python/tests/example_repos/example_feature_repo_with_ttl_0.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from datetime import timedelta
22

3-
from feast import Entity, FeatureView, Field, FileSource, ValueType
3+
from feast import Entity, FeatureView, Field, FileSource
44
from feast.types import Float32, Int32, Int64
55

66
driver_hourly_stats = FileSource(
@@ -9,7 +9,7 @@
99
created_timestamp_column="created",
1010
)
1111

12-
driver = Entity(name="driver_id", value_type=ValueType.INT64, description="driver id")
12+
driver = Entity(name="driver_id", description="driver id")
1313

1414

1515
driver_hourly_stats_view = FeatureView(

sdk/python/tests/integration/materialization/test_lambda.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ def test_lambda_materialization_consistency():
4545
fs = lambda_environment.feature_store
4646
driver = Entity(
4747
name="driver_id",
48-
join_key="driver_id",
49-
value_type=ValueType.INT64,
48+
join_keys=["driver_id"],
5049
)
5150

5251
driver_stats_fv = FeatureView(

0 commit comments

Comments
 (0)