Skip to content

Commit

Permalink
Instances of the FeatureServices are now used instead of only the n…
Browse files Browse the repository at this point in the history
…ames of the FeatureServices. (#3209)

* refactor: Return `FeatureService` instances instead of the service names

* refactor: Use a list of features or a `FeatureService` to get online or historical features

* refactor: Set the minimum version of feast to 0.12.0 to ensure the correct feast python API
  • Loading branch information
aiakide authored Nov 28, 2024
1 parent a31dabb commit c107805
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/zenml/integrations/feast/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class FeastIntegration(Integration):

NAME = FEAST
# click is added to keep the feast click version in sync with ZenML's click
REQUIREMENTS = ["feast", "click>=8.0.1,<8.1.4"]
REQUIREMENTS = ["feast>=0.12.0", "click>=8.0.1,<8.1.4"]
REQUIREMENTS_IGNORED_ON_UNINSTALL = ["click", "pandas"]

@classmethod
Expand Down
22 changes: 13 additions & 9 deletions src/zenml/integrations/feast/feature_stores/feast_feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from typing import Any, Dict, List, Union, cast

import pandas as pd
from feast import FeatureStore # type: ignore
from feast import FeatureService, FeatureStore # type: ignore
from feast.infra.registry.base_registry import BaseRegistry # type: ignore

from zenml.feature_stores.base_feature_store import BaseFeatureStore
Expand All @@ -43,14 +43,14 @@ def config(self) -> FeastFeatureStoreConfig:
def get_historical_features(
self,
entity_df: Union[pd.DataFrame, str],
features: List[str],
features: Union[List[str], FeatureService],
full_feature_names: bool = False,
) -> pd.DataFrame:
"""Returns the historical features for training or batch scoring.
Args:
entity_df: The entity DataFrame or entity name.
features: The features to retrieve.
features: The features to retrieve or a FeatureService.
full_feature_names: Whether to return the full feature names.
Raise:
Expand All @@ -70,14 +70,14 @@ def get_historical_features(
def get_online_features(
self,
entity_rows: List[Dict[str, Any]],
features: List[str],
features: Union[List[str], FeatureService],
full_feature_names: bool = False,
) -> Dict[str, Any]:
"""Returns the latest online feature data.
Args:
entity_rows: The entity rows to retrieve.
features: The features to retrieve.
features: The features to retrieve or a FeatureService.
full_feature_names: Whether to return the full feature names.
Raise:
Expand Down Expand Up @@ -118,17 +118,21 @@ def get_entities(self) -> List[str]:
fs = FeatureStore(repo_path=self.config.feast_repo)
return [ds.name for ds in fs.list_entities()]

def get_feature_services(self) -> List[str]:
"""Returns the feature service names.
def get_feature_services(self) -> List[FeatureService]:
"""Returns the feature services.
Raise:
ConnectionError: If the online component (Redis) is not available.
Returns:
The feature service names.
The feature services.
"""
fs = FeatureStore(repo_path=self.config.feast_repo)
return [ds.name for ds in fs.list_feature_services()]
feature_services: List[FeatureService] = list(
fs.list_feature_services()
)

return feature_services

def get_feature_views(self) -> List[str]:
"""Returns the feature view names.
Expand Down

0 comments on commit c107805

Please sign in to comment.