Skip to content

Commit

Permalink
chore: Adding unit test to test feature view dummy entity serializati…
Browse files Browse the repository at this point in the history
…on after apply() (feast-dev#4553)

* chore: Adding unit test to test feature view dummy entity serialization after apply()

Signed-off-by: Francisco Javier Arceo <[email protected]>

* updated

Signed-off-by: Francisco Javier Arceo <[email protected]>

---------

Signed-off-by: Francisco Javier Arceo <[email protected]>
  • Loading branch information
franciscojavierarceo authored Sep 21, 2024
1 parent 76b4576 commit 5a09a7e
Showing 1 changed file with 46 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from feast.entity import Entity
from feast.feast_object import ALL_RESOURCE_TYPES
from feast.feature_store import FeatureStore
from feast.feature_view import FeatureView
from feast.feature_view import DUMMY_ENTITY_ID, FeatureView
from feast.field import Field
from feast.infra.offline_stores.file_source import FileSource
from feast.infra.online_stores.sqlite import SqliteOnlineStoreConfig
Expand Down Expand Up @@ -342,6 +342,51 @@ def test_apply_entities_and_feature_views(test_feature_store):
test_feature_store.teardown()


@pytest.mark.parametrize(
"test_feature_store",
[lazy_fixture("feature_store_with_local_registry")],
)
def test_apply_dummuy_entity_and_feature_view_columns(test_feature_store):
assert isinstance(test_feature_store, FeatureStore)
# Create Feature Views
batch_source = FileSource(
file_format=ParquetFormat(),
path="file://feast/*",
timestamp_field="ts_col",
created_timestamp_column="timestamp",
)

e1 = Entity(name="fs1_my_entity_1", description="something")

fv = FeatureView(
name="my_feature_view_no_entity",
schema=[
Field(name="fs1_my_feature_1", dtype=Int64),
Field(name="fs1_my_feature_2", dtype=String),
Field(name="fs1_my_feature_3", dtype=Array(String)),
Field(name="fs1_my_feature_4", dtype=Array(Bytes)),
Field(name="fs1_my_entity_2", dtype=Int64),
],
entities=[],
tags={"team": "matchmaking"},
source=batch_source,
ttl=timedelta(minutes=5),
)

# Check that the entity_columns are empty before applying
assert fv.entity_columns == []

# Register Feature View
test_feature_store.apply([fv, e1])
fv_actual = test_feature_store.get_feature_view("my_feature_view_no_entity")

# Note that after the apply() the feature_view serializes the Dummy Entity ID
assert fv.entity_columns[0].name == DUMMY_ENTITY_ID
assert fv_actual.entity_columns[0].name == DUMMY_ENTITY_ID

test_feature_store.teardown()


@pytest.mark.parametrize(
"test_feature_store",
[lazy_fixture("feature_store_with_local_registry")],
Expand Down

0 comments on commit 5a09a7e

Please sign in to comment.