Skip to content

Commit e169729

Browse files
chore!: Deprecate positional arguments for feature services (feast-dev#3051)
* Clean up feature service Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Delete unnecessary feature service test Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Fix docstring Signed-off-by: Felix Wang <wangfelix98@gmail.com> Signed-off-by: Felix Wang <wangfelix98@gmail.com>
1 parent e04ad63 commit e169729

2 files changed

Lines changed: 13 additions & 54 deletions

File tree

sdk/python/feast/feature_service.py

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import warnings
21
from datetime import datetime
32
from typing import Dict, List, Optional, Union
43

@@ -53,9 +52,9 @@ class FeatureService:
5352
@log_exceptions
5453
def __init__(
5554
self,
56-
*args,
57-
name: Optional[str] = None,
58-
features: Optional[List[Union[FeatureView, OnDemandFeatureView]]] = None,
55+
*,
56+
name: str,
57+
features: List[Union[FeatureView, OnDemandFeatureView]],
5958
tags: Dict[str, str] = None,
6059
description: str = "",
6160
owner: str = "",
@@ -64,39 +63,17 @@ def __init__(
6463
"""
6564
Creates a FeatureService object.
6665
67-
Raises:
68-
ValueError: If one of the specified features is not a valid type.
66+
Args:
67+
name: The unique name of the feature service.
68+
feature_view_projections: A list containing feature views and feature view
69+
projections, representing the features in the feature service.
70+
description (optional): A human-readable description.
71+
tags (optional): A dictionary of key-value pairs to store arbitrary metadata.
72+
owner (optional): The owner of the feature view, typically the email of the
73+
primary maintainer.
6974
"""
70-
positional_attributes = ["name", "features"]
71-
_name = name
72-
_features = features
73-
if args:
74-
warnings.warn(
75-
(
76-
"Feature service parameters should be specified as a keyword argument instead of a positional arg."
77-
"Feast 0.24+ will not support positional arguments to construct feature service"
78-
),
79-
DeprecationWarning,
80-
)
81-
if len(args) > len(positional_attributes):
82-
raise ValueError(
83-
f"Only {', '.join(positional_attributes)} are allowed as positional args when defining "
84-
f"feature service, for backwards compatibility."
85-
)
86-
if len(args) >= 1:
87-
_name = args[0]
88-
if len(args) >= 2:
89-
_features = args[1]
90-
91-
if not _name:
92-
raise ValueError("Feature service name needs to be specified")
93-
94-
if not _features:
95-
# Technically, legal to create feature service with no feature views before.
96-
_features = []
97-
98-
self.name = _name
99-
self._features = _features
75+
self.name = name
76+
self._features = features
10077
self.feature_view_projections = []
10178
self.description = description
10279
self.tags = tags or {}

sdk/python/tests/unit/test_feature_service.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import pytest
2-
31
from feast.feature_service import FeatureService
42
from feast.feature_view import FeatureView
53
from feast.field import Field
@@ -59,22 +57,6 @@ def test_hash():
5957
assert len(s4) == 3
6058

6159

62-
def test_feature_view_kw_args_warning():
63-
with pytest.warns(DeprecationWarning):
64-
service = FeatureService("name", [], tags={"tag_1": "tag"}, description="desc")
65-
assert service.name == "name"
66-
assert service.tags == {"tag_1": "tag"}
67-
assert service.description == "desc"
68-
69-
# More positional args than name and features
70-
with pytest.raises(ValueError):
71-
service = FeatureService("name", [], {"tag_1": "tag"}, "desc")
72-
73-
# No name defined.
74-
with pytest.raises(ValueError):
75-
service = FeatureService(features=[], tags={"tag_1": "tag"}, description="desc")
76-
77-
7860
@no_warnings
7961
def test_feature_view_kw_args_normal():
8062
file_source = FileSource(name="my-file-source", path="test.parquet")

0 commit comments

Comments
 (0)