Skip to content

Commit

Permalink
aligning/rebase to master
Browse files Browse the repository at this point in the history
Signed-off-by: CS <[email protected]>
  • Loading branch information
SourdoughCat committed Jul 16, 2021
1 parent bf14c90 commit 0a4b2f6
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 6 deletions.
16 changes: 11 additions & 5 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os
from collections import OrderedDict, defaultdict
from collections import Counter, OrderedDict, defaultdict
from datetime import datetime, timedelta
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple, Union
Expand Down Expand Up @@ -330,7 +330,7 @@ def get_historical_features_by_view(
feature_refs: List[str],
start_date: Optional[datetime] = None,
end_date: Optional[datetime] = None,
full_feature_names: bool=False,
full_feature_names: bool = False,
) -> RetrievalJob:
"""Retrieve historical feature values for either training or batch scoring based on feature view.
Expand All @@ -356,6 +356,9 @@ def get_historical_features_by_view(
features.
end_date (datetime): End date for time range of data to filter the feature view before retrieving
features.
full_feature_names: A boolean that provides the option to add the feature view prefixes to the feature names,
changing them from the format "feature" to "feature_view__feature" (e.g., "daily_transactions" changes to
"customer_fv__daily_transactions"). By default, this value is set to False.
Returns:
RetrievalJob which can be used to materialize the results.
Expand All @@ -365,14 +368,17 @@ def get_historical_features_by_view(
>>> from feast.feature_store import FeatureStore
>>>
>>> fs = FeatureStore(config=RepoConfig(provider="gcp"))
>>> retrieval_job = fs.get_historical_features(
>>> entity_df="SELECT event_timestamp, order_id, customer_id from gcp_project.my_ds.customer_orders",
>>> fs = FeatureStore(config=RepoConfig(provider="local"))
>>> retrieval_job = fs.get_historical_features_by_view(
>>> entity_df="customer",
>>> feature_refs=["customer:age", "customer:avg_orders_1d", "customer:avg_orders_7d"]
>>> )
>>> feature_data = retrieval_job.to_df()
>>> model.fit(feature_data) # insert your modeling framework here.
"""
warn(
"This API is experimental and may change without any deprecation cycle in a future release."
)
all_feature_views = self._registry.list_feature_views(project=self.project)

_validate_feature_refs(feature_refs, full_feature_names)
Expand Down
2 changes: 2 additions & 0 deletions sdk/python/feast/infra/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def get_historical_features_by_view(
project: str,
start_date: Optional[datetime],
end_date: Optional[datetime],
full_feature_names: bool,
) -> RetrievalJob:
job = self.offline_store.get_historical_features_by_view(
config=config,
Expand All @@ -162,5 +163,6 @@ def get_historical_features_by_view(
project=project,
start_date=start_date,
end_date=end_date,
full_feature_names=full_feature_names,
)
return job
2 changes: 2 additions & 0 deletions sdk/python/feast/infra/gcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def get_historical_features_by_view(
project: str,
start_date: Optional[datetime],
end_date: Optional[datetime],
full_feature_names: bool,
) -> RetrievalJob:
job = self.offline_store.get_historical_features_by_view(
config=config,
Expand All @@ -164,5 +165,6 @@ def get_historical_features_by_view(
project=project,
start_date=start_date,
end_date=end_date,
full_feature_names=full_feature_names,
)
return job
2 changes: 2 additions & 0 deletions sdk/python/feast/infra/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ def get_historical_features_by_view(
project: str,
start_date: Optional[datetime],
end_date: Optional[datetime],
full_feature_names: bool,
) -> RetrievalJob:
return self.offline_store.get_historical_features_by_view(
config=config,
Expand All @@ -162,6 +163,7 @@ def get_historical_features_by_view(
project=project,
start_date=start_date,
end_date=end_date,
full_feature_names=full_feature_names,
)


Expand Down
1 change: 1 addition & 0 deletions sdk/python/feast/infra/offline_stores/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def get_historical_features_by_view(
project: str,
start_date: Optional[datetime],
end_date: Optional[datetime],
full_feature_names: bool,
):
raise NotImplementedError

Expand Down
9 changes: 8 additions & 1 deletion sdk/python/feast/infra/offline_stores/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ def get_historical_features_by_view(
project: str,
start_date: Optional[datetime],
end_date: Optional[datetime],
full_feature_names: bool,
):
if not (isinstance(entity_df, pd.DataFrame) or isinstance(entity_df, str)):
raise ValueError(
Expand Down Expand Up @@ -286,7 +287,13 @@ def get_historical_features_by_view(
)

return FileOfflineStore.get_historical_features(
config, feature_views, feature_refs, entity_df, registry, project,
config,
feature_views,
feature_refs,
entity_df,
registry,
project,
full_feature_names,
)

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions sdk/python/feast/infra/offline_stores/offline_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,6 @@ def get_historical_features_by_view(
project: str,
start_date: Optional[datetime],
end_date: Optional[datetime],
full_feature_names: bool,
):
pass
1 change: 1 addition & 0 deletions sdk/python/feast/infra/offline_stores/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@ def get_historical_features_by_view(
project: str,
start_date: Optional[datetime],
end_date: Optional[datetime],
full_feature_names: bool,
):
pass
1 change: 1 addition & 0 deletions sdk/python/feast/infra/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def get_historical_features_by_view(
project: str,
start_date: Optional[datetime],
end_date: Optional[datetime],
full_feature_names: bool,
) -> RetrievalJob:
pass

Expand Down
1 change: 1 addition & 0 deletions sdk/python/tests/foo_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def get_historical_features_by_view(
project: str,
start_date: Optional[datetime],
end_date: Optional[datetime],
full_feature_names: bool,
) -> RetrievalJob:
pass

Expand Down

0 comments on commit 0a4b2f6

Please sign in to comment.