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

compute_statistics #213

Merged
merged 3 commits into from
Jan 8, 2021
Merged
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
41 changes: 35 additions & 6 deletions python/hsfs/feature_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

class FeatureGroupBase:
def __init__(self, featurestore_id):
self._feature_group_base_engine = feature_group_base_engine.FeatureGroupBaseEngine(
featurestore_id
self._feature_group_base_engine = (
feature_group_base_engine.FeatureGroupBaseEngine(featurestore_id)
)
self._statistics_engine = statistics_engine.StatisticsEngine(
featurestore_id, self.ENTITY_TYPE
Expand Down Expand Up @@ -287,6 +287,27 @@ def get_statistics(self, commit_time: str = None):
else:
return self._statistics_engine.get(self, commit_time)

def compute_statistics(self):
"""Recompute the statistics for the feature group and save them to the
feature store.
Statistics are only computed for data in the offline storage of the feature
group.
# Returns
`Statistics`. The statistics metadata object.
# Raises
`RestAPIError`. Unable to persist the statistics.
"""
if self.statistics_config.enabled:
return self._statistics_engine.compute_statistics(self, self.read())
else:
warnings.warn(
(
"The statistics are not enabled of feature group `{}`, with version"
" `{}`. No statistics computed."
).format(self._name, self._version),
util.StorageWarning,
)


class FeatureGroup(FeatureGroupBase):
CACHED_FEATURE_GROUP = "CACHED_FEATURE_GROUP"
Expand Down Expand Up @@ -433,10 +454,18 @@ def read(
return (
self.select_all()
.as_of(wallclock_time)
.read(online, dataframe_type, read_options,)
.read(
online,
dataframe_type,
read_options,
)
)
else:
return self.select_all().read(online, dataframe_type, read_options,)
return self.select_all().read(
online,
dataframe_type,
read_options,
)

def read_changes(
self,
Expand Down Expand Up @@ -860,8 +889,8 @@ def __init__(
self._feat_hist_enabled = feat_hist_enabled
self._statistic_columns = statistic_columns

self._feature_group_engine = on_demand_feature_group_engine.OnDemandFeatureGroupEngine(
featurestore_id
self._feature_group_engine = (
on_demand_feature_group_engine.OnDemandFeatureGroupEngine(featurestore_id)
)

if self._id:
Expand Down