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 1 commit
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 @@ -433,10 +433,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 @@ -640,6 +648,27 @@ def commit_delete_record(
"""
self._feature_group_engine.commit_delete(self, delete_df, write_options)

def compute_statistics(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong. compute_statistics should be a member of the FeatureGroupBase class so that it can be used also by the on-demand feature groups

"""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,
)

def append_features(self, features):
"""Append features to the schema of the feature group.

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