Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Sep 21, 2024
Merged
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
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
Loading