-
Notifications
You must be signed in to change notification settings - Fork 1.4k
chore: Delete unused code in entity #3008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7da5afd
dd8af49
079eabd
b9ae6d3
f27ed49
f453ff7
c399923
a73a50b
1e028b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,6 @@ | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| import warnings | ||
| from datetime import datetime | ||
| from typing import Dict, List, Optional | ||
|
|
||
|
|
@@ -33,7 +32,10 @@ class Entity: | |
|
|
||
| Attributes: | ||
| name: The unique name of the entity. | ||
| value_type (deprecated): The type of the entity, such as string or float. | ||
| value_type: The type of the entity, such as string or float. | ||
| join_keys: A list of properties that uniquely identifies different entities within the | ||
| collection. This currently only supports a list of size one, but is intended to | ||
| eventually support multiple join keys. | ||
| join_key: A property that uniquely identifies different entities within the | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove join_key?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we haven't removed the usage of I clarified the TODO below |
||
| collection. The join_key property is typically used for joining entities | ||
| with their associated features. If not specified, defaults to the name. | ||
|
|
@@ -42,108 +44,62 @@ class Entity: | |
| owner: The owner of the entity, typically the email of the primary maintainer. | ||
| created_timestamp: The time when the entity was created. | ||
| last_updated_timestamp: The time when the entity was last updated. | ||
| join_keys: A list of properties that uniquely identifies different entities within the | ||
| collection. This is meant to replace the `join_key` parameter, but currently only | ||
| supports a list of size one. | ||
| """ | ||
|
|
||
| name: str | ||
| value_type: ValueType | ||
| join_keys: List[str] | ||
| join_key: str | ||
| description: str | ||
| tags: Dict[str, str] | ||
| owner: str | ||
| created_timestamp: Optional[datetime] | ||
| last_updated_timestamp: Optional[datetime] | ||
| join_keys: List[str] | ||
|
|
||
| @log_exceptions | ||
| def __init__( | ||
| self, | ||
| *args, | ||
| name: Optional[str] = None, | ||
| value_type: Optional[ValueType] = None, | ||
| *, | ||
| name: str, | ||
| join_keys: Optional[List[str]] = None, | ||
| description: str = "", | ||
| join_key: Optional[str] = None, | ||
| tags: Optional[Dict[str, str]] = None, | ||
| owner: str = "", | ||
| join_keys: Optional[List[str]] = None, | ||
| ): | ||
| """ | ||
| Creates an Entity object. | ||
|
|
||
| Args: | ||
| name: The unique name of the entity. | ||
| value_type (deprecated): The type of the entity, such as string or float. | ||
| description: A human-readable description. | ||
| join_key (deprecated): A property that uniquely identifies different entities within the | ||
| collection. The join_key property is typically used for joining entities | ||
| with their associated features. If not specified, defaults to the name. | ||
| tags: A dictionary of key-value pairs to store arbitrary metadata. | ||
| owner: The owner of the entity, typically the email of the primary maintainer. | ||
| join_keys: A list of properties that uniquely identifies different entities within the | ||
| collection. This is meant to replace the `join_key` parameter, but currently only | ||
| supports a list of size one. | ||
| join_keys (optional): A list of properties that uniquely identifies different entities | ||
| within the collection. This currently only supports a list of size one, but is | ||
| intended to eventually support multiple join keys. | ||
| description (optional): A human-readable description. | ||
| tags (optional): A dictionary of key-value pairs to store arbitrary metadata. | ||
| owner (optional): The owner of the entity, typically the email of the primary maintainer. | ||
|
|
||
| Raises: | ||
| ValueError: Parameters are specified incorrectly. | ||
| """ | ||
| if len(args) == 1: | ||
| warnings.warn( | ||
| ( | ||
| "Entity name should be specified as a keyword argument instead of a positional arg." | ||
| "Feast 0.24+ will not support positional arguments to construct Entities" | ||
| ), | ||
| DeprecationWarning, | ||
| ) | ||
| if len(args) > 1: | ||
| raise ValueError( | ||
| "All arguments to construct an entity should be specified as keyword arguments only" | ||
| ) | ||
|
|
||
| self.name = args[0] if len(args) > 0 else name | ||
|
|
||
| if not self.name: | ||
| raise ValueError("Name needs to be specified") | ||
|
|
||
| if value_type: | ||
| warnings.warn( | ||
| ( | ||
| "The `value_type` parameter is being deprecated. Instead, the type of an entity " | ||
| "should be specified as a Field in the schema of a feature view. Feast 0.24 and " | ||
| "onwards will not support the `value_type` parameter. The `entities` parameter of " | ||
| "feature views should also be changed to a List[Entity] instead of a List[str]; if " | ||
| "this is not done, entity columns will be mistakenly interpreted as feature columns." | ||
| ), | ||
| DeprecationWarning, | ||
| ) | ||
| self.value_type = value_type or ValueType.UNKNOWN | ||
| self.name = name | ||
| self.value_type = ValueType.UNKNOWN | ||
|
|
||
| # For now, both the `join_key` and `join_keys` attributes are set correctly, | ||
| # so both are usable. | ||
| # TODO(felixwang9817): Remove the usage of `join_key` throughout the codebase | ||
| # when the usage of `join_key` as a parameter is removed. | ||
| if join_key: | ||
| warnings.warn( | ||
| ( | ||
| "The `join_key` parameter is being deprecated in favor of the `join_keys` parameter. " | ||
| "Please switch from using `join_key` to `join_keys`. Feast 0.24 and onwards will not " | ||
| "support the `join_key` parameter." | ||
| ), | ||
| DeprecationWarning, | ||
| ) | ||
| self.join_keys = join_keys or [] | ||
| # TODO(felixwang9817): Fully remove the usage of `join_key` throughout the codebase, | ||
| # at which point the `join_key` attribute no longer needs to be set. | ||
| if join_keys and len(join_keys) > 1: | ||
| raise ValueError( | ||
| "An entity may only have single join key. " | ||
| "Multiple join keys will be supported in the future." | ||
| ) | ||
| if join_keys and len(join_keys) == 1: | ||
| elif join_keys and len(join_keys) == 1: | ||
| self.join_keys = join_keys | ||
| self.join_key = join_keys[0] | ||
| else: | ||
| self.join_key = join_key if join_key else self.name | ||
| if not self.join_keys: | ||
| self.join_key = self.name | ||
| self.join_keys = [self.join_key] | ||
|
|
||
| self.description = description | ||
| self.tags = tags if tags is not None else {} | ||
| self.owner = owner | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value type should be gone right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value_typeis still an attribute of an entity; it's just not set during initialization, but instead inferred during type inference