Skip to content

Commit

Permalink
Do not attempt to compute ODFVs when there are no ODFVs (#2090)
Browse files Browse the repository at this point in the history
* Do not attempt to compute ODFVs when there are no ODFVs

Signed-off-by: Felix Wang <[email protected]>

* Make on_demand_feature_views an optional parameter for retrieval jobs

Signed-off-by: Felix Wang <[email protected]>
  • Loading branch information
felixwang9817 authored Dec 2, 2021
1 parent fc9b767 commit ce84d38
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
12 changes: 5 additions & 7 deletions sdk/python/feast/infra/offline_stores/bigquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,7 @@ def pull_latest_from_table_or_query(

# When materializing a single feature view, we don't need full feature names. On demand transforms aren't materialized
return BigQueryRetrievalJob(
query=query,
client=client,
config=config,
full_feature_names=False,
on_demand_feature_views=None,
query=query, client=client, config=config, full_feature_names=False,
)

@staticmethod
Expand Down Expand Up @@ -200,7 +196,7 @@ def __init__(
client: bigquery.Client,
config: RepoConfig,
full_feature_names: bool,
on_demand_feature_views: Optional[List[OnDemandFeatureView]],
on_demand_feature_views: Optional[List[OnDemandFeatureView]] = None,
):
if not isinstance(query, str):
self._query_generator = query
Expand All @@ -215,7 +211,9 @@ def query_generator() -> Iterator[str]:
self.client = client
self.config = config
self._full_feature_names = full_feature_names
self._on_demand_feature_views = on_demand_feature_views
self._on_demand_feature_views = (
on_demand_feature_views if on_demand_feature_views else []
)

@property
def full_feature_names(self) -> bool:
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/feast/infra/offline_stores/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ def __init__(
self,
evaluation_function: Callable,
full_feature_names: bool,
on_demand_feature_views: Optional[List[OnDemandFeatureView]],
on_demand_feature_views: Optional[List[OnDemandFeatureView]] = None,
):
"""Initialize a lazy historical retrieval job"""

# The evaluation function executes a stored procedure to compute a historical retrieval.
self.evaluation_function = evaluation_function
self._full_feature_names = full_feature_names
self._on_demand_feature_views = on_demand_feature_views
self._on_demand_feature_views = (
on_demand_feature_views if on_demand_feature_views else []
)

@property
def full_feature_names(self) -> bool:
Expand Down Expand Up @@ -333,7 +335,5 @@ def evaluate_offline_job():

# When materializing a single feature view, we don't need full feature names. On demand transforms aren't materialized
return FileRetrievalJob(
evaluation_function=evaluate_offline_job,
full_feature_names=False,
on_demand_feature_views=None,
evaluation_function=evaluate_offline_job, full_feature_names=False,
)
4 changes: 2 additions & 2 deletions sdk/python/feast/infra/offline_stores/offline_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def on_demand_feature_views(self) -> Optional[List[OnDemandFeatureView]]:
def to_df(self) -> pd.DataFrame:
"""Return dataset as Pandas DataFrame synchronously including on demand transforms"""
features_df = self._to_df_internal()
if self.on_demand_feature_views is None:
if not self.on_demand_feature_views:
return features_df

# TODO(adchia): Fix requirement to specify dependent feature views in feature_refs
Expand All @@ -63,7 +63,7 @@ def _to_arrow_internal(self) -> pyarrow.Table:

def to_arrow(self) -> pyarrow.Table:
"""Return dataset as pyarrow Table synchronously"""
if self.on_demand_feature_views is None:
if not self.on_demand_feature_views:
return self._to_arrow_internal()

features_df = self._to_df_internal()
Expand Down
10 changes: 5 additions & 5 deletions sdk/python/feast/infra/offline_stores/redshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ def pull_latest_from_table_or_query(
s3_resource=s3_resource,
config=config,
full_feature_names=False,
on_demand_feature_views=None,
)

@staticmethod
Expand Down Expand Up @@ -189,7 +188,7 @@ def __init__(
s3_resource,
config: RepoConfig,
full_feature_names: bool,
on_demand_feature_views: Optional[List[OnDemandFeatureView]],
on_demand_feature_views: Optional[List[OnDemandFeatureView]] = None,
):
"""Initialize RedshiftRetrievalJob object.
Expand All @@ -199,7 +198,7 @@ def __init__(
s3_resource: boto3 s3 resource object
config: Feast repo config
full_feature_names: Whether to add the feature view prefixes to the feature names
on_demand_feature_views: A list of on demand transforms to apply at retrieval time
on_demand_feature_views (optional): A list of on demand transforms to apply at retrieval time
"""
if not isinstance(query, str):
self._query_generator = query
Expand All @@ -220,7 +219,9 @@ def query_generator() -> Iterator[str]:
+ str(uuid.uuid4())
)
self._full_feature_names = full_feature_names
self._on_demand_feature_views = on_demand_feature_views
self._on_demand_feature_views = (
on_demand_feature_views if on_demand_feature_views else []
)

@property
def full_feature_names(self) -> bool:
Expand Down Expand Up @@ -346,7 +347,6 @@ def _upload_entity_df_and_get_entity_schema(
s3_resource,
config,
full_feature_names=False,
on_demand_feature_views=None,
).to_df()
return dict(zip(limited_entity_df.columns, limited_entity_df.dtypes))
else:
Expand Down

0 comments on commit ce84d38

Please sign in to comment.