Skip to content

Commit de8a1b6

Browse files
Restore feature refs (feast-dev#1746)
* Ensure the features argument is not breaking Signed-off-by: Felix Wang <[email protected]> * Show DeprecationWarning for FeatureView input parameter only when necessary Signed-off-by: Felix Wang <[email protected]>
1 parent 6b9a79b commit de8a1b6

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed

sdk/python/feast/feature_store.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
import os
15+
import warnings
1516
from collections import Counter, OrderedDict, defaultdict
1617
from datetime import datetime, timedelta
1718
from pathlib import Path
@@ -43,6 +44,8 @@
4344
from feast.usage import log_exceptions, log_exceptions_and_usage
4445
from feast.version import get_version
4546

47+
warnings.simplefilter("once", DeprecationWarning)
48+
4649

4750
class FeatureStore:
4851
"""
@@ -219,7 +222,7 @@ def delete_feature_view(self, name: str):
219222

220223
def _get_features(
221224
self,
222-
features: Union[List[str], FeatureService],
225+
features: Optional[Union[List[str], FeatureService]],
223226
feature_refs: Optional[List[str]],
224227
) -> List[str]:
225228
_features = features or feature_refs
@@ -342,7 +345,7 @@ def teardown(self):
342345
def get_historical_features(
343346
self,
344347
entity_df: Union[pd.DataFrame, str],
345-
features: Union[List[str], FeatureService],
348+
features: Optional[Union[List[str], FeatureService]] = None,
346349
feature_refs: Optional[List[str]] = None,
347350
full_feature_names: bool = False,
348351
) -> RetrievalJob:
@@ -374,6 +377,9 @@ def get_historical_features(
374377
Returns:
375378
RetrievalJob which can be used to materialize the results.
376379
380+
Raises:
381+
ValueError: Both or neither of features and feature_refs are specified.
382+
377383
Examples:
378384
Retrieve historical features using a BigQuery SQL entity dataframe
379385
@@ -387,6 +393,22 @@ def get_historical_features(
387393
>>> feature_data = retrieval_job.to_df()
388394
>>> model.fit(feature_data) # insert your modeling framework here.
389395
"""
396+
if (features is not None and feature_refs is not None) or (
397+
features is None and feature_refs is None
398+
):
399+
raise ValueError(
400+
"You must specify exactly one of features and feature_refs."
401+
)
402+
403+
if feature_refs:
404+
warnings.warn(
405+
(
406+
"The argument 'feature_refs' is being deprecated. Please use 'features' "
407+
"instead. Feast 0.13 and onwards will not support the argument 'feature_refs'."
408+
),
409+
DeprecationWarning,
410+
)
411+
390412
_feature_refs = self._get_features(features, feature_refs)
391413

392414
all_feature_views = self._registry.list_feature_views(project=self.project)

sdk/python/feast/feature_view.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,14 @@ def __init__(
9393
Raises:
9494
ValueError: A field mapping conflicts with an Entity or a Feature.
9595
"""
96-
warnings.warn(
97-
(
98-
"The argument 'input' is being deprecated. Please use 'batch_source' "
99-
"instead. Feast 0.13 and onwards will not support the argument 'input'."
100-
),
101-
DeprecationWarning,
102-
)
96+
if input is not None:
97+
warnings.warn(
98+
(
99+
"The argument 'input' is being deprecated. Please use 'batch_source' "
100+
"instead. Feast 0.13 and onwards will not support the argument 'input'."
101+
),
102+
DeprecationWarning,
103+
)
103104

104105
_input = input or batch_source
105106
assert _input is not None

sdk/python/tests/integration/registration/test_feature_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ def test_apply_duplicated_featureview_names(feature_store_with_local_registry):
490490
entities=["driver_id"],
491491
ttl=timedelta(seconds=10),
492492
online=False,
493-
input=FileSource(path="driver_stats.parquet"),
493+
batch_source=FileSource(path="driver_stats.parquet"),
494494
tags={},
495495
)
496496

@@ -499,7 +499,7 @@ def test_apply_duplicated_featureview_names(feature_store_with_local_registry):
499499
entities=["id"],
500500
ttl=timedelta(seconds=10),
501501
online=False,
502-
input=FileSource(path="customer_stats.parquet"),
502+
batch_source=FileSource(path="customer_stats.parquet"),
503503
tags={},
504504
)
505505
try:

0 commit comments

Comments
 (0)