From c5160b2c80770d45f91a56e8fa3e17efe4ac3c1b Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 03:47:13 +0000 Subject: [PATCH 1/2] 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: feast-dev/feast#4670 Co-Authored-By: Francisco Javier Arceo Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- sdk/python/feast/entity.py | 8 ++++++++ sdk/python/tests/unit/test_entity.py | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/sdk/python/feast/entity.py b/sdk/python/feast/entity.py index 290e6307a42..40b5e09ced6 100644 --- a/sdk/python/feast/entity.py +++ b/sdk/python/feast/entity.py @@ -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 @@ -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: diff --git a/sdk/python/tests/unit/test_entity.py b/sdk/python/tests/unit/test_entity.py index 78f71231049..97341e19bd6 100644 --- a/sdk/python/tests/unit/test_entity.py +++ b/sdk/python/tests/unit/test_entity.py @@ -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 @@ -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 From 5338764bd5864eec54ff2bdeafbe3d69d6d0b85c Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Wed, 11 Dec 2024 03:51:46 +0000 Subject: [PATCH 2/2] style: Fix import sorting in entity files - Reorder imports according to PEP8 - Group standard library imports together - Fix ruff linting issues Co-Authored-By: Francisco Javier Arceo Signed-off-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- sdk/python/feast/entity.py | 2 +- sdk/python/tests/unit/test_entity.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/python/feast/entity.py b/sdk/python/feast/entity.py index 40b5e09ced6..9c529115c8e 100644 --- a/sdk/python/feast/entity.py +++ b/sdk/python/feast/entity.py @@ -11,9 +11,9 @@ # 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 -import warnings from google.protobuf.json_format import MessageToJson from typeguard import typechecked diff --git a/sdk/python/tests/unit/test_entity.py b/sdk/python/tests/unit/test_entity.py index 97341e19bd6..b36f363a6ff 100644 --- a/sdk/python/tests/unit/test_entity.py +++ b/sdk/python/tests/unit/test_entity.py @@ -11,9 +11,10 @@ # 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 + import assertpy import pytest -import warnings from feast.entity import Entity from feast.value_type import ValueType