Skip to content
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

Restore feature refs #1746

Merged
merged 2 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
26 changes: 24 additions & 2 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import warnings
from collections import Counter, OrderedDict, defaultdict
from datetime import datetime, timedelta
from pathlib import Path
Expand Down Expand Up @@ -43,6 +44,8 @@
from feast.usage import log_exceptions, log_exceptions_and_usage
from feast.version import get_version

warnings.simplefilter("once", DeprecationWarning)


class FeatureStore:
"""
Expand Down Expand Up @@ -219,7 +222,7 @@ def delete_feature_view(self, name: str):

def _get_features(
self,
features: Union[List[str], FeatureService],
features: Optional[Union[List[str], FeatureService]],
feature_refs: Optional[List[str]],
) -> List[str]:
_features = features or feature_refs
Expand Down Expand Up @@ -342,7 +345,7 @@ def teardown(self):
def get_historical_features(
self,
entity_df: Union[pd.DataFrame, str],
features: Union[List[str], FeatureService],
features: Optional[Union[List[str], FeatureService]] = None,
feature_refs: Optional[List[str]] = None,
full_feature_names: bool = False,
) -> RetrievalJob:
Expand Down Expand Up @@ -374,6 +377,9 @@ def get_historical_features(
Returns:
RetrievalJob which can be used to materialize the results.

Raises:
ValueError: Both or neither of features and feature_refs are specified.

Examples:
Retrieve historical features using a BigQuery SQL entity dataframe

Expand All @@ -387,6 +393,22 @@ def get_historical_features(
>>> feature_data = retrieval_job.to_df()
>>> model.fit(feature_data) # insert your modeling framework here.
"""
if (features is not None and feature_refs is not None) or (
features is None and feature_refs is None
):
raise ValueError(
"You must specify exactly one of features and feature_refs."
)

if feature_refs:
warnings.warn(
(
"The argument 'feature_refs' is being deprecated. Please use 'features' "
"instead. Feast 0.13 and onwards will not support the argument 'feature_refs'."
),
DeprecationWarning,
)

_feature_refs = self._get_features(features, feature_refs)

all_feature_views = self._registry.list_feature_views(project=self.project)
Expand Down
15 changes: 8 additions & 7 deletions sdk/python/feast/feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ def __init__(
Raises:
ValueError: A field mapping conflicts with an Entity or a Feature.
"""
warnings.warn(
(
"The argument 'input' is being deprecated. Please use 'batch_source' "
"instead. Feast 0.13 and onwards will not support the argument 'input'."
),
DeprecationWarning,
)
if input is not None:
warnings.warn(
(
"The argument 'input' is being deprecated. Please use 'batch_source' "
"instead. Feast 0.13 and onwards will not support the argument 'input'."
),
DeprecationWarning,
)

_input = input or batch_source
assert _input is not None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ def test_apply_duplicated_featureview_names(feature_store_with_local_registry):
entities=["driver_id"],
ttl=timedelta(seconds=10),
online=False,
input=FileSource(path="driver_stats.parquet"),
batch_source=FileSource(path="driver_stats.parquet"),
tags={},
)

Expand All @@ -499,7 +499,7 @@ def test_apply_duplicated_featureview_names(feature_store_with_local_registry):
entities=["id"],
ttl=timedelta(seconds=10),
online=False,
input=FileSource(path="customer_stats.parquet"),
batch_source=FileSource(path="customer_stats.parquet"),
tags={},
)
try:
Expand Down