Skip to content

Commit ccbfdf5

Browse files
SARAMALI15792ntkathole
authored andcommitted
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 Signed-off-by: SARAMALI15792 <[email protected]>
1 parent dca57e8 commit ccbfdf5

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
@@ -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._ensure_feature_view_name_is_unique(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,26 +1360,6 @@ 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()
1365-
if feature_view.name in name_to_fv_protos:
1366-
if not isinstance(
1367-
name_to_fv_protos.get(feature_view.name), feature_view.proto_class
1368-
):
1369-
raise ConflictingFeatureViewNames(feature_view.name)
1370-
1371-
def _existing_feature_view_names_to_fvs(self) -> Dict[str, Message]:
1372-
assert self.cached_registry_proto
1373-
odfvs = {
1374-
fv.spec.name: fv
1375-
for fv in self.cached_registry_proto.on_demand_feature_views
1376-
}
1377-
fvs = {fv.spec.name: fv for fv in self.cached_registry_proto.feature_views}
1378-
sfv = {
1379-
fv.spec.name: fv for fv in self.cached_registry_proto.stream_feature_views
1380-
}
1381-
return {**odfvs, **fvs, **sfv}
1382-
13831363
def get_permission(
13841364
self, name: str, project: str, allow_cache: bool = False
13851365
) -> Permission:

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2297,3 +2297,58 @@ def shared_odfv_name(inputs: pd.DataFrame) -> pd.DataFrame:
22972297
# Cleanup
22982298
test_registry.delete_feature_view("shared_odfv_name", project)
22992299
test_registry.teardown()
2300+
2301+
2302+
@pytest.mark.parametrize(
2303+
"test_registry",
2304+
all_fixtures,
2305+
)
2306+
def test_cross_project_feature_view_name_allowed(test_registry: BaseRegistry):
2307+
"""
2308+
Test that different projects can use the same feature view names.
2309+
This is a regression test for issue #6209.
2310+
"""
2311+
project_a = "project_a"
2312+
project_b = "project_b"
2313+
2314+
# Create a FeatureView in project A
2315+
feature_view_a = FeatureView(
2316+
name="shared_name",
2317+
entities=[],
2318+
schema=[Field(name="feature1", dtype=Float32)],
2319+
source=FileSource(path="data.parquet"),
2320+
)
2321+
2322+
# Create a StreamFeatureView with the same name in project B
2323+
stream_feature_view_b = StreamFeatureView(
2324+
name="shared_name",
2325+
entities=[],
2326+
schema=[Field(name="feature2", dtype=Float32)],
2327+
source=KafkaSource(
2328+
name="kafka_source",
2329+
kafka_bootstrap_servers="localhost:9092",
2330+
topic="test_topic",
2331+
timestamp_field="event_timestamp",
2332+
batch_source=FileSource(path="stream_data.parquet"),
2333+
),
2334+
aggregations=[],
2335+
)
2336+
2337+
# Both should apply successfully without ConflictingFeatureViewNames error
2338+
test_registry.apply_feature_view(feature_view_a, project_a)
2339+
test_registry.apply_feature_view(stream_feature_view_b, project_b)
2340+
2341+
# Verify both exist in their respective projects
2342+
retrieved_fv_a = test_registry.get_feature_view("shared_name", project_a)
2343+
assert retrieved_fv_a.name == "shared_name"
2344+
assert isinstance(retrieved_fv_a, FeatureView)
2345+
assert not isinstance(retrieved_fv_a, StreamFeatureView)
2346+
2347+
retrieved_sfv_b = test_registry.get_stream_feature_view("shared_name", project_b)
2348+
assert retrieved_sfv_b.name == "shared_name"
2349+
assert isinstance(retrieved_sfv_b, StreamFeatureView)
2350+
2351+
# Cleanup
2352+
test_registry.delete_feature_view("shared_name", project_a)
2353+
test_registry.delete_feature_view("shared_name", project_b)
2354+
test_registry.teardown()

0 commit comments

Comments
 (0)