Skip to content

Commit ce84d38

Browse files
Do not attempt to compute ODFVs when there are no ODFVs (#2090)
* Do not attempt to compute ODFVs when there are no ODFVs Signed-off-by: Felix Wang <wangfelix98@gmail.com> * Make on_demand_feature_views an optional parameter for retrieval jobs Signed-off-by: Felix Wang <wangfelix98@gmail.com>
1 parent fc9b767 commit ce84d38

4 files changed

Lines changed: 17 additions & 19 deletions

File tree

sdk/python/feast/infra/offline_stores/bigquery.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,7 @@ def pull_latest_from_table_or_query(
107107

108108
# When materializing a single feature view, we don't need full feature names. On demand transforms aren't materialized
109109
return BigQueryRetrievalJob(
110-
query=query,
111-
client=client,
112-
config=config,
113-
full_feature_names=False,
114-
on_demand_feature_views=None,
110+
query=query, client=client, config=config, full_feature_names=False,
115111
)
116112

117113
@staticmethod
@@ -200,7 +196,7 @@ def __init__(
200196
client: bigquery.Client,
201197
config: RepoConfig,
202198
full_feature_names: bool,
203-
on_demand_feature_views: Optional[List[OnDemandFeatureView]],
199+
on_demand_feature_views: Optional[List[OnDemandFeatureView]] = None,
204200
):
205201
if not isinstance(query, str):
206202
self._query_generator = query
@@ -215,7 +211,9 @@ def query_generator() -> Iterator[str]:
215211
self.client = client
216212
self.config = config
217213
self._full_feature_names = full_feature_names
218-
self._on_demand_feature_views = on_demand_feature_views
214+
self._on_demand_feature_views = (
215+
on_demand_feature_views if on_demand_feature_views else []
216+
)
219217

220218
@property
221219
def full_feature_names(self) -> bool:

sdk/python/feast/infra/offline_stores/file.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ def __init__(
3535
self,
3636
evaluation_function: Callable,
3737
full_feature_names: bool,
38-
on_demand_feature_views: Optional[List[OnDemandFeatureView]],
38+
on_demand_feature_views: Optional[List[OnDemandFeatureView]] = None,
3939
):
4040
"""Initialize a lazy historical retrieval job"""
4141

4242
# The evaluation function executes a stored procedure to compute a historical retrieval.
4343
self.evaluation_function = evaluation_function
4444
self._full_feature_names = full_feature_names
45-
self._on_demand_feature_views = on_demand_feature_views
45+
self._on_demand_feature_views = (
46+
on_demand_feature_views if on_demand_feature_views else []
47+
)
4648

4749
@property
4850
def full_feature_names(self) -> bool:
@@ -333,7 +335,5 @@ def evaluate_offline_job():
333335

334336
# When materializing a single feature view, we don't need full feature names. On demand transforms aren't materialized
335337
return FileRetrievalJob(
336-
evaluation_function=evaluate_offline_job,
337-
full_feature_names=False,
338-
on_demand_feature_views=None,
338+
evaluation_function=evaluate_offline_job, full_feature_names=False,
339339
)

sdk/python/feast/infra/offline_stores/offline_store.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def on_demand_feature_views(self) -> Optional[List[OnDemandFeatureView]]:
4141
def to_df(self) -> pd.DataFrame:
4242
"""Return dataset as Pandas DataFrame synchronously including on demand transforms"""
4343
features_df = self._to_df_internal()
44-
if self.on_demand_feature_views is None:
44+
if not self.on_demand_feature_views:
4545
return features_df
4646

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

6464
def to_arrow(self) -> pyarrow.Table:
6565
"""Return dataset as pyarrow Table synchronously"""
66-
if self.on_demand_feature_views is None:
66+
if not self.on_demand_feature_views:
6767
return self._to_arrow_internal()
6868

6969
features_df = self._to_df_internal()

sdk/python/feast/infra/offline_stores/redshift.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ def pull_latest_from_table_or_query(
101101
s3_resource=s3_resource,
102102
config=config,
103103
full_feature_names=False,
104-
on_demand_feature_views=None,
105104
)
106105

107106
@staticmethod
@@ -189,7 +188,7 @@ def __init__(
189188
s3_resource,
190189
config: RepoConfig,
191190
full_feature_names: bool,
192-
on_demand_feature_views: Optional[List[OnDemandFeatureView]],
191+
on_demand_feature_views: Optional[List[OnDemandFeatureView]] = None,
193192
):
194193
"""Initialize RedshiftRetrievalJob object.
195194
@@ -199,7 +198,7 @@ def __init__(
199198
s3_resource: boto3 s3 resource object
200199
config: Feast repo config
201200
full_feature_names: Whether to add the feature view prefixes to the feature names
202-
on_demand_feature_views: A list of on demand transforms to apply at retrieval time
201+
on_demand_feature_views (optional): A list of on demand transforms to apply at retrieval time
203202
"""
204203
if not isinstance(query, str):
205204
self._query_generator = query
@@ -220,7 +219,9 @@ def query_generator() -> Iterator[str]:
220219
+ str(uuid.uuid4())
221220
)
222221
self._full_feature_names = full_feature_names
223-
self._on_demand_feature_views = on_demand_feature_views
222+
self._on_demand_feature_views = (
223+
on_demand_feature_views if on_demand_feature_views else []
224+
)
224225

225226
@property
226227
def full_feature_names(self) -> bool:
@@ -346,7 +347,6 @@ def _upload_entity_df_and_get_entity_schema(
346347
s3_resource,
347348
config,
348349
full_feature_names=False,
349-
on_demand_feature_views=None,
350350
).to_df()
351351
return dict(zip(limited_entity_df.columns, limited_entity_df.dtypes))
352352
else:

0 commit comments

Comments
 (0)