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
1514from datetime import datetime
1615from 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
0 commit comments