Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat: Make entity value_type mandatory with deprecation warning
- Add deprecation warning when value_type is not specified for an entity
- Add test cases to verify deprecation warning behavior
- Prepare for making value_type mandatory in next release

Issue: #4670

Co-Authored-By: Francisco Javier Arceo <arceofrancisco@gmail.com>
Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
  • Loading branch information
commit c5160b2c80770d45f91a56e8fa3e17efe4ac3c1b
8 changes: 8 additions & 0 deletions sdk/python/feast/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
from datetime import datetime
from typing import Dict, List, Optional
import warnings

from google.protobuf.json_format import MessageToJson
from typeguard import typechecked
Expand Down Expand Up @@ -79,6 +80,13 @@ def __init__(
ValueError: Parameters are specified incorrectly.
"""
self.name = name
if value_type is None:
warnings.warn(
"Entity value_type will be mandatory in the next release. "
"Please specify a value_type for entity '%s'." % name,
DeprecationWarning,
stacklevel=2,
)
self.value_type = value_type or ValueType.UNKNOWN

if join_keys and len(join_keys) > 1:
Expand Down
14 changes: 14 additions & 0 deletions sdk/python/tests/unit/test_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.
import assertpy
import pytest
import warnings

from feast.entity import Entity
from feast.value_type import ValueType
Expand Down Expand Up @@ -73,3 +74,16 @@ def test_hash():

s4 = {entity1, entity2, entity3, entity4}
assert len(s4) == 3


def test_entity_without_value_type_warns():
with pytest.warns(DeprecationWarning, match="Entity value_type will be mandatory"):
entity = Entity(name="my-entity")
assert entity.value_type == ValueType.UNKNOWN


def test_entity_with_value_type_no_warning():
with warnings.catch_warnings():
warnings.simplefilter("error")
entity = Entity(name="my-entity", value_type=ValueType.STRING)
assert entity.value_type == ValueType.STRING