Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
f1fd9b8
Allow specifying FeatureServices in FeatureStore methods
achals Jul 6, 2021
27ea33e
format and lint
achals Jul 6, 2021
7ae1ed3
features_refs -> features
achals Jul 6, 2021
6269200
remote type: ignores
achals Jul 6, 2021
8574163
implement applying and persisting feature services into registry
achals Jul 6, 2021
dbe2995
Fix integration test references
achals Jul 6, 2021
7efd3c3
Add backwards compatibility
achals Jul 6, 2021
3e54197
More lint
achals Jul 6, 2021
3e6cad3
add integration tests
achals Jul 7, 2021
86a528a
refactor and lint
achals Jul 7, 2021
a929aa4
More tests
achals Jul 7, 2021
0368903
Add cli commands
achals Jul 7, 2021
7633674
Update sdk/python/feast/feature_store.py
achals Jul 7, 2021
f48542f
Update sdk/python/feast/feature_store.py
achals Jul 7, 2021
42c6a5f
Update sdk/python/feast/feature_store.py
achals Jul 7, 2021
f612ab3
Update sdk/python/feast/feature_store.py
achals Jul 7, 2021
8fe06c1
Update tests to use file offline source
achals Jul 7, 2021
7248a4c
Make tests integration and lint
achals Jul 7, 2021
09a651d
Retrieve feature services to avoid stale references
achals Jul 7, 2021
8dc58aa
Fix lint
achals Jul 7, 2021
6f09686
Merge changes from master
achals Jul 9, 2021
c656190
Merge master into branch
achals Jul 9, 2021
9540c72
fix tests
achals Jul 9, 2021
4241885
fix import
achals Jul 9, 2021
77ab6c0
fix integ tests
achals Jul 9, 2021
6eac6e8
CR
achals Jul 9, 2021
976293b
format
achals Jul 9, 2021
e1f9a07
Fix integ test
achals Jul 10, 2021
52a6507
Fix integ test
achals Jul 10, 2021
8a91fc1
Merge branch 'master' into achal/feature-service-api
achals Jul 12, 2021
c457f1e
Rename in comments
achals Jul 12, 2021
e3d70a9
Docstrings for Feature Services
achals Jul 12, 2021
545f675
make format
achals Jul 12, 2021
a77eb0f
merge from master
achals Jul 14, 2021
eaa3a89
format and refactor
achals Jul 14, 2021
e3cebc1
docs and updates
achals Jul 14, 2021
8a1534e
Update docs/concepts/feature-service.md
achals Jul 14, 2021
3274a1e
Update sdk/python/feast/feature_service.py
achals Jul 14, 2021
39bf511
Update sdk/python/feast/feature_service.py
achals Jul 14, 2021
2133abc
docs docs docs
achals Jul 14, 2021
f6938c0
docs docs
achals Jul 14, 2021
d495856
merge from master
achals Jul 19, 2021
1317d08
Fixes after merge
achals Jul 19, 2021
ea2210d
Remove dupe
achals Jul 19, 2021
2f0d698
Renames and deletions
achals Jul 19, 2021
ac211d2
lint
achals Jul 19, 2021
23c0d80
format and tests
achals Jul 19, 2021
798df64
remove unused imports
achals Jul 19, 2021
81fb228
fix registry
achals Jul 19, 2021
21aa6b6
fix docs
achals Jul 19, 2021
a6ecc6d
fix dangling print
achals Jul 20, 2021
54c95ae
make format and lint
achals Jul 20, 2021
2394f0a
list feature servces
achals Jul 20, 2021
2d11ab4
Merge branch 'master' into achal/feature-service-api
achals Jul 22, 2021
1ed9592
Merge from master
achals Jul 22, 2021
2a48ae8
fix tests
achals Jul 22, 2021
0943faf
Remove unused file
achals Jul 22, 2021
03d0ba5
single heading
achals Jul 22, 2021
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
Prev Previous commit
Next Next commit
Merge changes from master
  • Loading branch information
achals committed Jul 9, 2021
commit 6f096867b6d8a685443cc213c11d5fb8a2131c5c
73 changes: 46 additions & 27 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

from feast import utils
from feast.entity import Entity
from feast.errors import FeastProviderLoginError, FeatureViewNotFoundException
from feast.feature_service import FeatureService
from feast.errors import FeatureNameCollisionError, FeatureViewNotFoundException
from feast.feature_view import FeatureView
from feast.inference import (
update_data_sources_with_inferred_event_timestamp_col,
Expand Down Expand Up @@ -304,6 +304,7 @@ def get_historical_features(
entity_df: Union[pd.DataFrame, str],
features: Union[List[str], FeatureService],
feature_refs: Optional[List[str]] = None,
full_feature_names: bool = False,
) -> RetrievalJob:
"""Enrich an entity dataframe with historical feature values for either training or batch scoring.

Expand Down Expand Up @@ -346,10 +347,11 @@ def get_historical_features(
>>> model.fit(feature_data) # insert your modeling framework here.
"""
all_feature_views = self._registry.list_feature_views(project=self.project)
try:
feature_views = _get_requested_feature_views(features, all_feature_views)
except FeatureViewNotFoundException as e:
sys.exit(e)

_validate_feature_refs(feature_refs, full_feature_names)
feature_views = list(
view for view, _ in _group_feature_refs(feature_refs, all_feature_views)
)

_features = features or feature_refs
if not _features:
Expand All @@ -365,17 +367,16 @@ def get_historical_features(
_feature_refs = _features

provider = self._get_provider()
try:
job = provider.get_historical_features(
self.config,
feature_views,
_feature_refs,
entity_df,
self._registry,
self.project,
)
except FeastProviderLoginError as e:
sys.exit(e)

job = provider.get_historical_features(
self.config,
feature_views,
feature_refs,
entity_df,
self._registry,
self.project,
full_feature_names,
)

return job

Expand Down Expand Up @@ -545,6 +546,7 @@ def get_online_features(
features: Union[List[str], FeatureService],
Comment thread
woop marked this conversation as resolved.
Outdated
entity_rows: List[Dict[str, Any]],
feature_refs: Optional[List[str]] = None,
full_feature_names: bool = False,
) -> OnlineResponse:
"""
Retrieves the latest online feature data.
Expand Down Expand Up @@ -620,7 +622,8 @@ def get_online_features(
project=self.project, allow_cache=True
)

grouped_refs = _group_refs(_features, all_feature_views)
_validate_feature_refs(feature_refs, full_feature_names)
grouped_refs = _group_feature_refs(feature_refs, all_feature_views)
for table, requested_features in grouped_refs:
entity_keys = _get_table_entity_keys(
table, union_of_entity_keys, entity_name_to_join_key_map
Expand Down Expand Up @@ -679,8 +682,32 @@ def _entity_row_to_field_values(
return result


def _group_refs(
features: Union[List[str], FeatureService], all_feature_views: List[FeatureView],
def _validate_feature_refs(feature_refs: Union[List[str], FeatureService], full_feature_names: bool = False):
collided_feature_refs = []

if full_feature_names:
collided_feature_refs = [
ref for ref, occurrences in Counter(feature_refs).items() if occurrences > 1
]
else:
feature_names = [ref.split(":")[1] for ref in feature_refs]
collided_feature_names = [
ref
for ref, occurrences in Counter(feature_names).items()
if occurrences > 1
]

for feature_name in collided_feature_names:
collided_feature_refs.extend(
[ref for ref in feature_refs if ref.endswith(":" + feature_name)]
)

if len(collided_feature_refs) > 0:
raise FeatureNameCollisionError(collided_feature_refs, full_feature_names)


def _group_feature_refs(
features: Union[List[str], FeatureService], all_feature_views: List[FeatureView]
) -> List[Tuple[FeatureView, List[str]]]:
""" Get list of feature views and corresponding feature names based on feature references"""

Expand Down Expand Up @@ -714,14 +741,6 @@ def _get_features_refs_from_feature_services(
return [f"{feature_service.name}:{f.name}" for f in feature_service.features]
Comment thread
achals marked this conversation as resolved.
Outdated


def _get_requested_feature_views(
features: Union[List[str], FeatureService], all_feature_views: List[FeatureView],
) -> List[FeatureView]:
"""Get list of feature views based on feature references"""
# TODO: Get rid of this function. We only need _group_refs
return list(view for view, _ in _group_refs(features, all_feature_views))


def _get_table_entity_keys(
table: FeatureView, entity_keys: List[EntityKeyProto], join_key_map: Dict[str, str],
) -> List[EntityKeyProto]:
Expand Down
1 change: 1 addition & 0 deletions sdk/python/tests/test_offline_online_store_consistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def check_offline_and_online_features(
{"driver_id": [driver_id], "event_timestamp": [event_timestamp]}
),
features=[f"{fv.name}:value"],
full_feature_names=full_feature_names,
).to_df()

if full_feature_names:
Expand Down
4 changes: 3 additions & 1 deletion sdk/python/tests/test_online_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ def test_online() -> None:
# invalid table reference
with pytest.raises(FeatureViewNotFoundException):
store.get_online_features(
features=["driver_locations_bad:lon"], entity_rows=[{"driver": 1}],
features=["driver_locations_bad:lon"],
entity_rows=[{"driver": 1}],
full_feature_names=False,
)

# Create new FeatureStore object with fast cache invalidation
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.