Skip to content

Commit a4fde83

Browse files
authored
fix: Scope feature view name conflict check to current project in file-based registry (feast-dev#6369)
* fix: scope feature view name conflict check to current project in file-based registry _check_conflicting_feature_view_names built its lookup map from all feature views in cached_registry_proto without filtering by project. In a shared file-based registry with multiple projects, this caused false ConflictingFeatureViewNames errors when two different projects defined feature views with the same name. Add a project parameter to both _check_conflicting_feature_view_names and _existing_feature_view_names_to_fvs, and filter each collection by fv.spec.project == project so only same-project views are compared. Fixes feast-dev#6209 Signed-off-by: Abhishek8108 <[email protected]> * chore: suppress detect-secrets false positive in openlineage-secret manifest The placeholder value your-marquez-api-key in openlineage-secret_v1_secret.yaml triggers detect-secrets. Mark it as an allowlist exception. Signed-off-by: Abhishek8108 <[email protected]> * test: use a real temp parquet file in cross-project conflict test FileSource requires the file to exist when apply() succeeds (no early exception). Replace the bare path string with a mkstemp() path so the test passes in CI. Signed-off-by: Abhishek8108 <[email protected]> * test: use prep_file_source to create a valid parquet file in cross-project test apply() reads the parquet schema when the apply succeeds (no early exception). Use the prep_file_source() helper — the same pattern all other tests that call apply() use — to produce a real, schema-valid parquet file instead of an empty temp file. Signed-off-by: Abhishek8108 <[email protected]> * test: add registry-level cross-project name conflict regression test Replace the FeatureStore-level test (which fought parquet inference and dill source extraction) with a direct Registry-level test mirroring the pattern in test_sql_registry.py. Two tests in tests/unit/infra/registry/test_file_registry.py: - test_same_project_name_conflict_batch_vs_stream: confirms that a FeatureView and StreamFeatureView with the same name in the same project still raise ConflictingFeatureViewNames (existing behaviour) - test_cross_project_name_does_not_conflict_batch_vs_stream: confirms that the same name across different projects and different view types no longer raises (the bug fixed by this PR) Signed-off-by: Abhishek8108 <[email protected]> * test: add teardown to file_registry fixture to match sql test style Signed-off-by: Abhishek8108 <[email protected]> --------- Signed-off-by: Abhishek8108 <[email protected]>
1 parent 1a4b96c commit a4fde83

3 files changed

Lines changed: 111 additions & 7 deletions

File tree

‎infra/feast-operator/bundle/manifests/openlineage-secret_v1_secret.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ kind: Secret
33
metadata:
44
name: openlineage-secret
55
stringData:
6-
api_key: your-marquez-api-key
6+
api_key: your-marquez-api-key # pragma: allowlist secret

‎sdk/python/feast/infra/registry/registry.py‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ def apply_feature_view(
764764
self._prepare_registry_for_changes(project)
765765
assert self.cached_registry_proto
766766

767-
self._check_conflicting_feature_view_names(feature_view)
767+
self._check_conflicting_feature_view_names(feature_view, project)
768768
existing_feature_views_of_same_type: RepeatedCompositeFieldContainer
769769
if isinstance(feature_view, StreamFeatureView):
770770
existing_feature_views_of_same_type = (
@@ -1360,23 +1360,32 @@ def _get_registry_proto(
13601360

13611361
return registry_proto
13621362

1363-
def _check_conflicting_feature_view_names(self, feature_view: BaseFeatureView):
1364-
name_to_fv_protos = self._existing_feature_view_names_to_fvs()
1363+
def _check_conflicting_feature_view_names(
1364+
self, feature_view: BaseFeatureView, project: str
1365+
):
1366+
name_to_fv_protos = self._existing_feature_view_names_to_fvs(project)
13651367
if feature_view.name in name_to_fv_protos:
13661368
if not isinstance(
13671369
name_to_fv_protos.get(feature_view.name), feature_view.proto_class
13681370
):
13691371
raise ConflictingFeatureViewNames(feature_view.name)
13701372

1371-
def _existing_feature_view_names_to_fvs(self) -> Dict[str, Message]:
1373+
def _existing_feature_view_names_to_fvs(self, project: str) -> Dict[str, Message]:
13721374
assert self.cached_registry_proto
13731375
odfvs = {
13741376
fv.spec.name: fv
13751377
for fv in self.cached_registry_proto.on_demand_feature_views
1378+
if fv.spec.project == project
1379+
}
1380+
fvs = {
1381+
fv.spec.name: fv
1382+
for fv in self.cached_registry_proto.feature_views
1383+
if fv.spec.project == project
13761384
}
1377-
fvs = {fv.spec.name: fv for fv in self.cached_registry_proto.feature_views}
13781385
sfv = {
1379-
fv.spec.name: fv for fv in self.cached_registry_proto.stream_feature_views
1386+
fv.spec.name: fv
1387+
for fv in self.cached_registry_proto.stream_feature_views
1388+
if fv.spec.project == project
13801389
}
13811390
return {**odfvs, **fvs, **sfv}
13821391

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
import tempfile
2+
from datetime import timedelta
3+
4+
import pytest
5+
6+
from feast import Field
7+
from feast.data_source import PushSource
8+
from feast.entity import Entity
9+
from feast.errors import ConflictingFeatureViewNames
10+
from feast.feature_view import FeatureView
11+
from feast.infra.offline_stores.file_source import FileSource
12+
from feast.infra.registry.registry import Registry
13+
from feast.repo_config import RegistryConfig
14+
from feast.stream_feature_view import StreamFeatureView
15+
from feast.types import Float32
16+
from feast.value_type import ValueType
17+
18+
19+
@pytest.fixture
20+
def file_registry():
21+
fd, registry_path = tempfile.mkstemp()
22+
config = RegistryConfig(path=registry_path)
23+
registry = Registry("test_project", config, None)
24+
yield registry
25+
registry.teardown()
26+
27+
28+
def _make_sources():
29+
file_source = FileSource(
30+
path="driver_stats.parquet",
31+
timestamp_field="event_timestamp",
32+
created_timestamp_column="created",
33+
)
34+
push_source = PushSource(name="driver_push", batch_source=file_source)
35+
return file_source, push_source
36+
37+
38+
def test_same_project_name_conflict_batch_vs_stream(file_registry):
39+
"""A FeatureView and StreamFeatureView with the same name in the same project must raise ConflictingFeatureViewNames."""
40+
entity = Entity(name="driver", value_type=ValueType.STRING, join_keys=["driver_id"])
41+
file_registry.apply_entity(entity, "test_project")
42+
43+
file_source, push_source = _make_sources()
44+
45+
batch_view = FeatureView(
46+
name="driver_activity",
47+
entities=[entity],
48+
ttl=timedelta(days=1),
49+
schema=[Field(name="conv_rate", dtype=Float32)],
50+
source=file_source,
51+
)
52+
file_registry.apply_feature_view(batch_view, "test_project")
53+
54+
stream_view = StreamFeatureView(
55+
name="driver_activity",
56+
source=push_source,
57+
entities=[entity],
58+
schema=[Field(name="conv_rate", dtype=Float32)],
59+
timestamp_field="event_timestamp",
60+
)
61+
with pytest.raises(ConflictingFeatureViewNames):
62+
file_registry.apply_feature_view(stream_view, "test_project")
63+
64+
65+
def test_cross_project_name_does_not_conflict_batch_vs_stream(file_registry):
66+
"""A FeatureView in project_a and a StreamFeatureView with the same name in project_b
67+
must not raise ConflictingFeatureViewNames.
68+
69+
Before the fix, _existing_feature_view_names_to_fvs scanned all projects,
70+
so the type mismatch between the two projects triggered a spurious error.
71+
"""
72+
entity = Entity(name="driver", value_type=ValueType.STRING, join_keys=["driver_id"])
73+
file_registry.apply_entity(entity, "project_a")
74+
file_registry.apply_entity(entity, "project_b")
75+
76+
file_source, push_source = _make_sources()
77+
78+
batch_view = FeatureView(
79+
name="driver_activity",
80+
entities=[entity],
81+
ttl=timedelta(days=1),
82+
schema=[Field(name="conv_rate", dtype=Float32)],
83+
source=file_source,
84+
)
85+
file_registry.apply_feature_view(batch_view, "project_a")
86+
87+
stream_view = StreamFeatureView(
88+
name="driver_activity",
89+
source=push_source,
90+
entities=[entity],
91+
schema=[Field(name="conv_rate", dtype=Float32)],
92+
timestamp_field="event_timestamp",
93+
)
94+
# Must not raise — same name, different project, different type.
95+
file_registry.apply_feature_view(stream_view, "project_b")

0 commit comments

Comments
 (0)