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

Python docs formatting fixes #1473

Merged
merged 2 commits into from
Apr 22, 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
13 changes: 3 additions & 10 deletions sdk/python/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,12 +37,6 @@ Feature View
.. automodule:: feast.feature_view
:members:

Feature Table
==================

.. automodule:: feast.feature_table
:members:

Feature
==================

Expand Down
5 changes: 4 additions & 1 deletion sdk/python/feast/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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.
"""
Expand Down
45 changes: 21 additions & 24 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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"))
Expand All @@ -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
Expand Down Expand Up @@ -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
>>>
Expand All @@ -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
Expand Down Expand Up @@ -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
>>>
Expand All @@ -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
Expand Down Expand Up @@ -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]}
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions sdk/python/feast/repo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 """
jklegar marked this conversation as resolved.
Show resolved Hide resolved
jklegar marked this conversation as resolved.
Show resolved Hide resolved

project: StrictStr
""" str: Feast project id. This can be any alphanumeric string up to 16 characters.
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/tests/test_online_retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
(
Expand All @@ -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=[
(
Expand All @@ -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=[
(
Expand Down Expand Up @@ -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,
)
)
Expand Down Expand Up @@ -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,
)
)
Expand Down