diff --git a/sdk/python/docs/index.rst b/sdk/python/docs/index.rst index 5e6c03b85f..b8dfb6e914 100644 --- a/sdk/python/docs/index.rst +++ b/sdk/python/docs/index.rst @@ -3,25 +3,24 @@ Feast Python API Documentation Feature Store ---------------------------- +================== .. automodule:: feast.feature_store :members: - :undoc-members: - :show-inheritance: Config ================== .. automodule:: feast.repo_config :members: - :exclude-members: load_repo_config + :exclude-members: load_repo_config, FeastBaseModel Data Source ================== .. automodule:: feast.data_source :members: + :exclude-members: KafkaOptions, KafkaSource, KinesisOptions, KinesisSource Entity @@ -38,12 +37,6 @@ Feature View .. automodule:: feast.feature_view :members: -Feature Table -================== - -.. automodule:: feast.feature_table - :members: - Feature ================== diff --git a/sdk/python/feast/feature.py b/sdk/python/feast/feature.py index 6136c3db2b..1eec6d6bd8 100644 --- a/sdk/python/feast/feature.py +++ b/sdk/python/feast/feature.py @@ -110,7 +110,8 @@ def __init__(self, name: str, feature_table: str): def from_proto(cls, proto: FeatureRefProto): """ Construct a feature reference from the given FeatureReference proto - Arg: + + Args: proto: Protobuf FeatureReference to construct from Returns: FeatureRef that refers to the given feature @@ -124,6 +125,7 @@ def from_str(cls, feature_ref_str: str): String feature reference should be in the format feature_table:feature. Where "feature_table" and "name" are the feature_table name and feature name respectively. + Args: feature_ref_str: String representation of the feature reference Returns: @@ -144,6 +146,7 @@ def from_str(cls, feature_ref_str: str): def to_proto(self) -> FeatureRefProto: """ Convert and return this feature table reference to protobuf. + Returns: Protobuf respresentation of this feature table reference. """ diff --git a/sdk/python/feast/feature_store.py b/sdk/python/feast/feature_store.py index 8810749f62..ccc1ae111c 100644 --- a/sdk/python/feast/feature_store.py +++ b/sdk/python/feast/feature_store.py @@ -41,6 +41,10 @@ class FeatureStore: """ A FeatureStore object is used to define, create, and retrieve features. + + Args: + repo_path: Path to a `feature_store.yaml` used to configure the feature store + config (RepoConfig): Configuration object used to configure the feature store """ config: RepoConfig @@ -50,12 +54,6 @@ class FeatureStore: def __init__( self, repo_path: Optional[str] = None, config: Optional[RepoConfig] = None, ): - """ Initializes a new FeatureStore object. Used to manage a feature store. - - Args: - repo_path: Path to a `feature_store.yaml` used to configure the feature store - config (RepoConfig): Configuration object used to configure the feature store - """ if repo_path is not None and config is not None: raise ValueError("You cannot specify both repo_path and config") if config is not None: @@ -188,11 +186,13 @@ def apply( infrastructure (e.g., create tables in an online store) in order to reflect these new definitions. All operations are idempotent, meaning they can safely be rerun. - Args: objects (List[Union[FeatureView, Entity]]): A list of FeatureView or Entity objects that should be - registered + Args: + objects (List[Union[FeatureView, Entity]]): A list of FeatureView or Entity objects that should be + registered Examples: Register a single Entity and FeatureView. + >>> from feast.feature_store import FeatureStore >>> from feast import Entity, FeatureView, Feature, ValueType, FileSource >>> from datetime import timedelta @@ -219,16 +219,16 @@ def apply( views_to_update = [] for ob in objects: if isinstance(ob, FeatureView): - self._registry.apply_feature_view(ob, project=self.config.project) + self._registry.apply_feature_view(ob, project=self.project) views_to_update.append(ob) elif isinstance(ob, Entity): - self._registry.apply_entity(ob, project=self.config.project) + self._registry.apply_entity(ob, project=self.project) else: raise ValueError( f"Unknown object type ({type(ob)}) provided as part of apply() call" ) self._get_provider().update_infra( - project=self.config.project, + project=self.project, tables_to_delete=[], tables_to_keep=views_to_update, partial=True, @@ -263,6 +263,7 @@ def get_historical_features( Examples: Retrieve historical features using a BigQuery SQL entity dataframe + >>> from feast.feature_store import FeatureStore >>> >>> fs = FeatureStore(config=RepoConfig(provider="gcp")) @@ -275,9 +276,7 @@ def get_historical_features( """ self._tele.log("get_historical_features") - all_feature_views = self._registry.list_feature_views( - project=self.config.project - ) + all_feature_views = self._registry.list_feature_views(project=self.project) try: feature_views = _get_requested_feature_views( feature_refs, all_feature_views @@ -319,6 +318,7 @@ def materialize_incremental( Examples: Materialize all features into the online store up to 5 minutes ago. + >>> from datetime import datetime, timedelta >>> from feast.feature_store import FeatureStore >>> @@ -330,13 +330,11 @@ def materialize_incremental( feature_views_to_materialize = [] if feature_views is None: feature_views_to_materialize = self._registry.list_feature_views( - self.config.project + self.project ) else: for name in feature_views: - feature_view = self._registry.get_feature_view( - name, self.config.project - ) + feature_view = self._registry.get_feature_view(name, self.project) feature_views_to_materialize.append(feature_view) # TODO paging large loads @@ -378,6 +376,7 @@ def materialize( Examples: Materialize all features into the online store over the interval from 3 hours ago to 10 minutes ago. + >>> from datetime import datetime, timedelta >>> from feast.feature_store import FeatureStore >>> @@ -396,13 +395,11 @@ def materialize( feature_views_to_materialize = [] if feature_views is None: feature_views_to_materialize = self._registry.list_feature_views( - self.config.project + self.project ) else: for name in feature_views: - feature_view = self._registry.get_feature_view( - name, self.config.project - ) + feature_view = self._registry.get_feature_view(name, self.project) feature_views_to_materialize.append(feature_view) # TODO paging large loads @@ -445,7 +442,7 @@ def get_online_features( >>> entity_rows = [{"customer_id": 0},{"customer_id": 1}] >>> >>> online_response = store.get_online_features( - >>> feature_refs, entity_rows, project="my_project") + >>> feature_refs, entity_rows) >>> online_response_dict = online_response.to_dict() >>> print(online_response_dict) {'sales:daily_transactions': [1.1,1.2], 'sales:customer_id': [0,1]} @@ -481,7 +478,7 @@ def get_online_features( result_rows.append(_entity_row_to_field_values(entity_row_proto)) all_feature_views = self._registry.list_feature_views( - project=self.config.project, allow_cache=True + project=self.project, allow_cache=True ) grouped_refs = _group_refs(feature_refs, all_feature_views) diff --git a/sdk/python/feast/repo_config.py b/sdk/python/feast/repo_config.py index bedcf5c53a..bb18119b42 100644 --- a/sdk/python/feast/repo_config.py +++ b/sdk/python/feast/repo_config.py @@ -41,7 +41,7 @@ class RegistryConfig(FeastBaseModel): """ Metadata Store Configuration. Configuration that relates to reading from and writing to the Feast registry.""" path: StrictStr - """ str: Path to metadata store. Can be a local path, or remote object storage path, e.g. gcs://foo/bar """ + """ str: Path to metadata store. Can be a local path, or remote object storage path, e.g. a GCS URI """ cache_ttl_seconds: StrictInt = 600 """int: The cache TTL is the amount of time registry state will be cached in memory. If this TTL is exceeded then @@ -54,7 +54,7 @@ class RepoConfig(FeastBaseModel): """ Repo config. Typically loaded from `feature_store.yaml` """ registry: Union[StrictStr, RegistryConfig] = "data/registry.db" - """ str: Path to metadata store. Can be a local path, or remote object storage path, e.g. gcs://foo/bar """ + """ str: Path to metadata store. Can be a local path, or remote object storage path, e.g. a GCS URI """ project: StrictStr """ str: Feast project id. This can be any alphanumeric string up to 16 characters. diff --git a/sdk/python/tests/test_online_retrieval.py b/sdk/python/tests/test_online_retrieval.py index 856595188d..8925268727 100644 --- a/sdk/python/tests/test_online_retrieval.py +++ b/sdk/python/tests/test_online_retrieval.py @@ -32,7 +32,7 @@ def test_online() -> None: join_keys=["driver"], entity_values=[ValueProto(int64_val=1)] ) provider.online_write_batch( - project=store.config.project, + project=store.project, table=driver_locations_fv, data=[ ( @@ -52,7 +52,7 @@ def test_online() -> None: join_keys=["customer"], entity_values=[ValueProto(int64_val=5)] ) provider.online_write_batch( - project=store.config.project, + project=store.project, table=customer_profile_fv, data=[ ( @@ -74,7 +74,7 @@ def test_online() -> None: entity_values=[ValueProto(int64_val=5), ValueProto(int64_val=1)], ) provider.online_write_batch( - project=store.config.project, + project=store.project, table=customer_driver_combined_fv, data=[ ( @@ -130,7 +130,7 @@ def test_online() -> None: path=store.config.registry, cache_ttl_seconds=cache_ttl ), online_store=store.config.online_store, - project=store.config.project, + project=store.project, provider=store.config.provider, ) ) @@ -189,7 +189,7 @@ def test_online() -> None: path=store.config.registry, cache_ttl_seconds=0 ), online_store=store.config.online_store, - project=store.config.project, + project=store.project, provider=store.config.provider, ) )