Skip to content

Commit

Permalink
On demand feature group append (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
SirOibaf authored Nov 11, 2020
1 parent b263ed3 commit f50efa5
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 104 deletions.
68 changes: 53 additions & 15 deletions python/hsfs/core/feature_group_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,51 +24,89 @@ def __init__(self, featurestore_id):
)

def delete(self):
self._feature_group_base_engine.delete(self)
"""Drop the entire feature group along with its feature data.
!!! danger "Potentially dangerous operation"
This operation drops all metadata associated with **this version** of the
feature group **and** all the feature data in offline and online storage
associated with it.
# Raises
`RestAPIError`.
"""
self._feature_group_engine.delete(self)

def select_all(self):
"""Select all features in the feature group and return a query object."""
"""Select all features in the feature group and return a query object.
The query can be used to construct joins of feature groups or create a
training dataset immediately.
# Returns
`Query`. A query object with all features of the feature group.
"""
return query.Query(
self._feature_store_name, self._feature_store_id, self, self._features
)

def select(self, features=[]):
"""Select a subset of features of the feature group and return a query object.
The query can be used to construct joins of feature groups or create a training
dataset with a subset of features of the feature group.
# Arguments
features: list, optional. A list of `Feature` objects or feature names as
strings to be selected, defaults to [].
# Returns
`Query`: A query object with the selected features of the feature group.
"""
return query.Query(
self._feature_store_name, self._feature_store_id, self, features
)

def add_tag(self, name, value=None):
def add_tag(self, name: str, value: str = None):
"""Attach a name/value tag to a feature group.
A tag can consist of a name only or a name/value pair. Tag names are
unique identifiers.
:param name: name of the tag to be added
:type name: str
:param value: value of the tag to be added, defaults to None
:type value: str, optional
# Arguments
name: Name of the tag to be added.
value: Value of the tag to be added, defaults to `None`.
# Raises
`RestAPIError`.
"""
self._feature_group_base_engine.add_tag(self, name, value)

def delete_tag(self, name):
def delete_tag(self, name: str):
"""Delete a tag from a feature group.
Tag names are unique identifiers.
:param name: name of the tag to be removed
:type name: str
# Arguments
name: Name of the tag to be removed.
# Raises
`RestAPIError`.
"""
self._feature_group_base_engine.delete_tag(self, name)

def get_tag(self, name=None):
def get_tag(self, name: str = None):
"""Get the tags of a feature group.
Tag names are unique identifiers. Returns all tags if no tag name is
specified.
:param name: name of the tag to get, defaults to None
:type name: str, optional
:return: list of tags as name/value pairs
:rtype: list of dict
# Arguments
name: Name of the tag to get, defaults to `None`.
# Returns
`list[Tag]`. List of tags as name/value pairs.
# Raises
`RestAPIError`.
"""
return self._feature_group_base_engine.get_tags(self, name)
88 changes: 0 additions & 88 deletions python/hsfs/feature_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,36 +222,6 @@ def show(self, n: int, online: Optional[bool] = False):
)
return self.select_all().show(n, online)

def select_all(self):
"""Select all features in the feature group and return a query object.
The query can be used to construct joins of feature groups or create a
training dataset immediately.
# Returns
`Query`. A query object with all features of the feature group.
"""
return query.Query(
self._feature_store_name, self._feature_store_id, self, self._features
)

def select(self, features=[]):
"""Select a subset of features of the feature group and return a query object.
The query can be used to construct joins of feature groups or create a training
dataset with a subset of features of the feature group.
# Arguments
features: list, optional. A list of `Feature` objects or feature names as
strings to be selected, defaults to [].
# Returns
`Query`: A query object with the selected features of the feature group.
"""
return query.Query(
self._feature_store_name, self._feature_store_id, self, features
)

def save(
self,
features: Union[
Expand Down Expand Up @@ -383,19 +353,6 @@ def commit_details(self, limit: Optional[int] = None):
"""
return self._feature_group_engine.commit_details(self, limit)

def delete(self):
"""Drop the entire feature group along with its feature data.
!!! danger "Potentially dangerous operation"
This operation drops all metadata associated with **this version** of the
feature group **and** all the feature data in offline and online storage
associated with it.
# Raises
`RestAPIError`.
"""
self._feature_group_engine.delete(self)

def commit_delete_record(
self,
delete_df: TypeVar("pyspark.sql.DataFrame"), # noqa: F821
Expand Down Expand Up @@ -499,51 +456,6 @@ def append_features(self, features):
self._feature_group_engine.append_features(self, new_features)
return self

def add_tag(self, name: str, value: str = None):
"""Attach a name/value tag to a feature group.
A tag can consist of a name only or a name/value pair. Tag names are
unique identifiers.
# Arguments
name: Name of the tag to be added.
value: Value of the tag to be added, defaults to `None`.
# Raises
`RestAPIError`.
"""
self._feature_group_engine.add_tag(self, name, value)

def delete_tag(self, name: str):
"""Delete a tag from a feature group.
Tag names are unique identifiers.
# Arguments
name: Name of the tag to be removed.
# Raises
`RestAPIError`.
"""
self._feature_group_engine.delete_tag(self, name)

def get_tag(self, name: str = None):
"""Get the tags of a feature group.
Tag names are unique identifiers. Returns all tags if no tag name is
specified.
# Arguments
name: Name of the tag to get, defaults to `None`.
# Returns
`list[Tag]`. List of tags as name/value pairs.
# Raises
`RestAPIError`.
"""
return self._feature_group_engine.get_tags(self, name)

@classmethod
def from_response_json(cls, json_dict):
json_decamelized = humps.decamelize(json_dict)
Expand Down
2 changes: 1 addition & 1 deletion python/hsfs/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def get_feature_group(self, name: str, version: int = None):
name, version, feature_group_api.FeatureGroupApi.CACHED
)

def get_on_demand_feature_group(self, name: str, version: int =None):
def get_on_demand_feature_group(self, name: str, version: int = None):
"""Get a on-demand feature group entity from the feature store.
Getting a on-demand feature group from the Feature Store means getting its
Expand Down

0 comments on commit f50efa5

Please sign in to comment.