Skip to content
Merged
Show file tree
Hide file tree
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
30 changes: 20 additions & 10 deletions sdk/python/feast/feature_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -2404,8 +2404,9 @@ def _materialize_odfv(
):
"""Helper to materialize a single OnDemandFeatureView."""
if not feature_view.source_feature_view_projections:
print(
f"[WARNING] ODFV {feature_view.name} materialization: No source feature views found."
_logger.warning(
"ODFV %s materialization: No source feature views found.",
feature_view.name,
)
return
start_date = utils.make_tzaware(start_date)
Expand All @@ -2432,20 +2433,27 @@ def _materialize_odfv(
all_join_keys = {key for key in all_join_keys if key}

if not all_join_keys:
print(
f"[WARNING] ODFV {feature_view.name} materialization: No join keys found in source views. Cannot create entity_df. Skipping."
_logger.warning(
"ODFV %s materialization: No join keys found in source views. "
"Cannot create entity_df. Skipping.",
feature_view.name,
)
return

if len(entity_timestamp_col_names) > 1:
print(
f"[WARNING] ODFV {feature_view.name} materialization: Found multiple timestamp columns in sources ({entity_timestamp_col_names}). This is not supported. Skipping."
_logger.warning(
"ODFV %s materialization: Found multiple timestamp columns in "
"sources (%s). This is not supported. Skipping.",
feature_view.name,
entity_timestamp_col_names,
)
return

if not entity_timestamp_col_names:
print(
f"[WARNING] ODFV {feature_view.name} materialization: No batch sources with timestamp columns found for sources. Skipping."
_logger.warning(
"ODFV %s materialization: No batch sources with timestamp "
"columns found for sources. Skipping.",
feature_view.name,
)
return

Expand Down Expand Up @@ -2474,8 +2482,10 @@ def _materialize_odfv(
all_source_dfs.append(df)

if not all_source_dfs:
print(
f"No source data found for ODFV {feature_view.name} in the given time range. Skipping materialization."
_logger.warning(
"No source data found for ODFV %s in the given time range. "
"Skipping materialization.",
feature_view.name,
)
return

Expand Down
28 changes: 28 additions & 0 deletions sdk/python/tests/unit/test_unit_feature_store.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
from dataclasses import dataclass
from datetime import datetime
from typing import Dict, List
from unittest.mock import MagicMock, patch

Expand Down Expand Up @@ -181,3 +183,29 @@ def test_write_to_offline_store_resolves_feature_view_with_single_lookup():
registry.get_label_view.assert_not_called()

provider.ingest_df_to_offline_store.assert_called_once()


def test_materialize_odfv_reports_skips_through_the_logger(caplog, capsys):
"""``_materialize_odfv`` must report a skipped materialization via the logger.

The method gives up on five different conditions and returns without materializing
anything. Those messages went to stdout with a hand-rolled ``[WARNING]`` prefix, so a
user's logging configuration could not silence, redirect or capture them, and nothing
about the skip reached the log.
"""
store = FeatureStore.__new__(FeatureStore)

feature_view = MagicMock()
feature_view.name = "driver_hourly_stats_odfv"
feature_view.source_feature_view_projections = {}

with caplog.at_level(logging.WARNING, logger="feast.feature_store"):
store._materialize_odfv(
feature_view,
start_date=datetime(2024, 1, 1),
end_date=datetime(2024, 1, 2),
full_feature_names=False,
)

assert "No source feature views found" in caplog.text
assert capsys.readouterr().out == ""
Loading