Skip to content

Commit

Permalink
chore: Adding additional dummy entity field test (feast-dev#4602)
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Javier Arceo <[email protected]>
  • Loading branch information
franciscojavierarceo authored Oct 5, 2024
1 parent 10ce2aa commit 9646f03
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
4 changes: 4 additions & 0 deletions sdk/python/feast/feature_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
name=DUMMY_ENTITY_NAME,
join_keys=[DUMMY_ENTITY_ID],
)
DUMMY_ENTITY_FIELD = Field(
name=DUMMY_ENTITY_ID,
dtype=from_value_type(ValueType.STRING),
)


@typechecked
Expand Down
40 changes: 36 additions & 4 deletions sdk/python/tests/unit/test_on_demand_python_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@
RequestSource,
)
from feast.driver_test_data import create_driver_hourly_stats_df
from feast.feature_view import DUMMY_ENTITY_FIELD
from feast.field import Field
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
from feast.on_demand_feature_view import on_demand_feature_view
from feast.types import Array, Bool, Float32, Float64, Int64, String
from feast.types import (
Array,
Bool,
Float32,
Float64,
Int64,
String,
ValueType,
from_value_type,
)


class TestOnDemandPythonTransformation(unittest.TestCase):
Expand Down Expand Up @@ -51,7 +61,9 @@ def setUp(self):
path=driver_stats_path, allow_truncated_timestamps=True
)

driver = Entity(name="driver", join_keys=["driver_id"])
driver = Entity(
name="driver", join_keys=["driver_id"], value_type=ValueType.INT64
)

driver_stats_source = FileSource(
name="driver_hourly_stats_source",
Expand All @@ -73,6 +85,19 @@ def setUp(self):
source=driver_stats_source,
)

driver_stats_entity_less_fv = FeatureView(
name="driver_hourly_stats_no_entity",
entities=[],
ttl=timedelta(days=0),
schema=[
Field(name="conv_rate", dtype=Float32),
Field(name="acc_rate", dtype=Float32),
Field(name="avg_daily_trips", dtype=Int64),
],
online=True,
source=driver_stats_source,
)

@on_demand_feature_view(
sources=[driver_stats_fv],
schema=[Field(name="conv_rate_plus_acc_pandas", dtype=Float64)],
Expand Down Expand Up @@ -151,6 +176,7 @@ def python_singleton_view(inputs: dict[str, Any]) -> dict[str, Any]:
pandas_view,
python_view,
python_singleton_view,
driver_stats_entity_less_fv,
]
)

Expand All @@ -162,13 +188,19 @@ def python_singleton_view(inputs: dict[str, Any]) -> dict[str, Any]:
pandas_view,
python_view,
python_demo_view,
driver_stats_entity_less_fv,
]
)
self.store.write_to_online_store(
feature_view_name="driver_hourly_stats", df=driver_df
)
assert len(self.store.list_all_feature_views()) == 4
assert len(self.store.list_feature_views()) == 1
assert driver_stats_fv.entity_columns == [
Field(name=driver.join_key, dtype=from_value_type(driver.value_type))
]
assert driver_stats_entity_less_fv.entity_columns == [DUMMY_ENTITY_FIELD]

assert len(self.store.list_all_feature_views()) == 5
assert len(self.store.list_feature_views()) == 2
assert len(self.store.list_on_demand_feature_views()) == 3
assert len(self.store.list_stream_feature_views()) == 0

Expand Down

0 comments on commit 9646f03

Please sign in to comment.