Skip to content

Commit

Permalink
Deprecate the input parameter for FeatureViews
Browse files Browse the repository at this point in the history
Signed-off-by: Felix Wang <[email protected]>
  • Loading branch information
felixwang9817 committed Aug 7, 2021
1 parent 54bbe5f commit c95df72
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 31 deletions.
34 changes: 10 additions & 24 deletions sdk/python/feast/feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ class FeatureView:
ttl: The amount of time this group of features lives. A ttl of 0 indicates that
this group of features lives forever. Note that large ttl's or a ttl of 0
can result in extremely computationally intensive queries.
input: The source of data where this group of features is stored.
batch_source (optional): The batch source of data where this group of features
is stored.
batch_source: The batch source of data where this group of features is stored.
stream_source (optional): The stream source of data where this group of features
is stored.
features (optional): The set of features defined as part of this FeatureView.
Expand All @@ -67,7 +65,6 @@ class FeatureView:
tags: Optional[Dict[str, str]]
ttl: timedelta
online: bool
input: DataSource
batch_source: DataSource
stream_source: Optional[DataSource] = None
created_timestamp: Optional[datetime] = None
Expand All @@ -80,8 +77,7 @@ def __init__(
name: str,
entities: List[str],
ttl: Union[Duration, timedelta],
input: Optional[DataSource] = None,
batch_source: Optional[DataSource] = None,
batch_source: DataSource,
stream_source: Optional[DataSource] = None,
features: Optional[List[Feature]] = None,
tags: Optional[Dict[str, str]] = None,
Expand All @@ -93,26 +89,17 @@ def __init__(
Raises:
ValueError: A field mapping conflicts with an Entity or a Feature.
"""
if input is not None:
warnings.warn(
(
"The argument 'input' is being deprecated. Please use 'batch_source' "
"instead. Feast 0.13 and onwards will not support the argument 'input'."
),
DeprecationWarning,
)

_input = input or batch_source
assert _input is not None

_features = features or []

cols = [entity for entity in entities] + [feat.name for feat in _features]
for col in cols:
if _input.field_mapping is not None and col in _input.field_mapping.keys():
if (
batch_source.field_mapping is not None
and col in batch_source.field_mapping.keys()
):
raise ValueError(
f"The field {col} is mapped to {_input.field_mapping[col]} for this data source. "
f"Please either remove this field mapping or use {_input.field_mapping[col]} as the "
f"The field {col} is mapped to {batch_source.field_mapping[col]} for this data source. "
f"Please either remove this field mapping or use {batch_source.field_mapping[col]} as the "
f"Entity or Feature name."
)

Expand All @@ -127,8 +114,7 @@ def __init__(
self.ttl = ttl

self.online = online
self.input = _input
self.batch_source = _input
self.batch_source = batch_source
self.stream_source = stream_source

self.materialization_intervals = []
Expand Down Expand Up @@ -311,7 +297,7 @@ def most_recent_end_time(self) -> Optional[datetime]:

def infer_features_from_batch_source(self, config: RepoConfig):
"""
Infers the set of features associated to this feature view from the input source.
Infers the set of features associated to this feature view from the batch source.
Args:
config: Configuration object used to configure the feature store.
Expand Down
8 changes: 4 additions & 4 deletions sdk/python/feast/infra/offline_stores/offline_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def get_feature_view_query_context(
join_keys = []
entity_selections = []
reverse_field_mapping = {
v: k for k, v in feature_view.input.field_mapping.items()
v: k for k, v in feature_view.batch_source.field_mapping.items()
}
for entity_name in feature_view.entities:
entity = registry.get_entity(entity_name, project)
Expand All @@ -120,8 +120,8 @@ def get_feature_view_query_context(
else:
ttl_seconds = 0

event_timestamp_column = feature_view.input.event_timestamp_column
created_timestamp_column = feature_view.input.created_timestamp_column
event_timestamp_column = feature_view.batch_source.event_timestamp_column
created_timestamp_column = feature_view.batch_source.created_timestamp_column

context = FeatureViewQueryContext(
name=feature_view.name,
Expand All @@ -135,7 +135,7 @@ def get_feature_view_query_context(
created_timestamp_column, created_timestamp_column
),
# TODO: Make created column optional and not hardcoded
table_subquery=feature_view.input.get_table_query_string(),
table_subquery=feature_view.batch_source.get_table_query_string(),
entity_selections=entity_selections,
)
query_context.append(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name="driver_hourly_stats", # Intentionally use the same FeatureView name
entities=["driver_id"],
online=False,
input=driver_hourly_stats,
batch_source=driver_hourly_stats,
ttl=Duration(seconds=10),
tags={},
)
Expand All @@ -19,7 +19,7 @@
name="driver_hourly_stats", # Intentionally use the same FeatureView name
entities=["driver_id"],
online=False,
input=driver_hourly_stats,
batch_source=driver_hourly_stats,
ttl=Duration(seconds=10),
tags={},
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ def correctness_feature_view(data_source: DataSource) -> FeatureView:
entities=["driver"],
features=[Feature("value", ValueType.FLOAT)],
ttl=timedelta(days=5),
input=data_source,
batch_source=data_source,
)

0 comments on commit c95df72

Please sign in to comment.