Skip to content

Commit 5ca8ea5

Browse files
author
CakeHub Developer
committed
fix: Scope feature view name conflict checks by project in file registry
The file-based registry was incorrectly checking for feature view name conflicts across all projects in a shared registry, causing false positives when different projects used the same feature view names. This fix replaces the custom conflict checking logic with the base class method _ensure_feature_view_name_is_unique, which properly scopes checks by project. This aligns the file registry behavior with the SQL registry implementation. Changes: - Use _ensure_feature_view_name_is_unique from BaseRegistry (same as SQL registry) - Remove _check_conflicting_feature_view_names and _existing_feature_view_names_to_fvs methods - Add regression test for cross-project feature view names Fixes feast-dev#6209
1 parent 3a0a814 commit 5ca8ea5

2 files changed

Lines changed: 56 additions & 21 deletions

File tree

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

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ def apply_feature_view(
755755
self._prepare_registry_for_changes(project)
756756
assert self.cached_registry_proto
757757

758-
self._check_conflicting_feature_view_names(feature_view)
758+
self._ensure_feature_view_name_is_unique(feature_view, project)
759759
existing_feature_views_of_same_type: RepeatedCompositeFieldContainer
760760
if isinstance(feature_view, StreamFeatureView):
761761
existing_feature_views_of_same_type = (
@@ -1351,26 +1351,6 @@ def _get_registry_proto(
13511351

13521352
return registry_proto
13531353

1354-
def _check_conflicting_feature_view_names(self, feature_view: BaseFeatureView):
1355-
name_to_fv_protos = self._existing_feature_view_names_to_fvs()
1356-
if feature_view.name in name_to_fv_protos:
1357-
if not isinstance(
1358-
name_to_fv_protos.get(feature_view.name), feature_view.proto_class
1359-
):
1360-
raise ConflictingFeatureViewNames(feature_view.name)
1361-
1362-
def _existing_feature_view_names_to_fvs(self) -> Dict[str, Message]:
1363-
assert self.cached_registry_proto
1364-
odfvs = {
1365-
fv.spec.name: fv
1366-
for fv in self.cached_registry_proto.on_demand_feature_views
1367-
}
1368-
fvs = {fv.spec.name: fv for fv in self.cached_registry_proto.feature_views}
1369-
sfv = {
1370-
fv.spec.name: fv for fv in self.cached_registry_proto.stream_feature_views
1371-
}
1372-
return {**odfvs, **fvs, **sfv}
1373-
13741354
def get_permission(
13751355
self, name: str, project: str, allow_cache: bool = False
13761356
) -> Permission:

‎sdk/python/tests/integration/registration/test_universal_registry.py‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,3 +2192,58 @@ def shared_odfv_name(inputs: pd.DataFrame) -> pd.DataFrame:
21922192
# Cleanup
21932193
test_registry.delete_feature_view("shared_odfv_name", project)
21942194
test_registry.teardown()
2195+
2196+
2197+
@pytest.mark.parametrize(
2198+
"test_registry",
2199+
all_fixtures,
2200+
)
2201+
def test_cross_project_feature_view_name_allowed(test_registry: BaseRegistry):
2202+
"""
2203+
Test that different projects can use the same feature view names.
2204+
This is a regression test for issue #6209.
2205+
"""
2206+
project_a = "project_a"
2207+
project_b = "project_b"
2208+
2209+
# Create a FeatureView in project A
2210+
feature_view_a = FeatureView(
2211+
name="shared_name",
2212+
entities=[],
2213+
schema=[Field(name="feature1", dtype=Float32)],
2214+
source=FileSource(path="data.parquet"),
2215+
)
2216+
2217+
# Create a StreamFeatureView with the same name in project B
2218+
stream_feature_view_b = StreamFeatureView(
2219+
name="shared_name",
2220+
entities=[],
2221+
schema=[Field(name="feature2", dtype=Float32)],
2222+
source=KafkaSource(
2223+
name="kafka_source",
2224+
kafka_bootstrap_servers="localhost:9092",
2225+
topic="test_topic",
2226+
timestamp_field="event_timestamp",
2227+
batch_source=FileSource(path="stream_data.parquet"),
2228+
),
2229+
aggregations=[],
2230+
)
2231+
2232+
# Both should apply successfully without ConflictingFeatureViewNames error
2233+
test_registry.apply_feature_view(feature_view_a, project_a)
2234+
test_registry.apply_feature_view(stream_feature_view_b, project_b)
2235+
2236+
# Verify both exist in their respective projects
2237+
retrieved_fv_a = test_registry.get_feature_view("shared_name", project_a)
2238+
assert retrieved_fv_a.name == "shared_name"
2239+
assert isinstance(retrieved_fv_a, FeatureView)
2240+
assert not isinstance(retrieved_fv_a, StreamFeatureView)
2241+
2242+
retrieved_sfv_b = test_registry.get_stream_feature_view("shared_name", project_b)
2243+
assert retrieved_sfv_b.name == "shared_name"
2244+
assert isinstance(retrieved_sfv_b, StreamFeatureView)
2245+
2246+
# Cleanup
2247+
test_registry.delete_feature_view("shared_name", project_a)
2248+
test_registry.delete_feature_view("shared_name", project_b)
2249+
test_registry.teardown()

0 commit comments

Comments
 (0)