Skip to content

Commit 1d640b6

Browse files
committed
fix: ODFV not getting counted in resource count
Signed-off-by: ntkathole <nikhilkathole2683@gmail.com>
1 parent 021e9ea commit 1d640b6

File tree

2 files changed

+86
-2
lines changed

2 files changed

+86
-2
lines changed

sdk/python/feast/api/registry/rest/metrics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ def count_resources_for_project(project_name: str):
9898
features = {"features": []}
9999
try:
100100
feature_views = grpc_call(
101-
grpc_handler.ListFeatureViews,
102-
RegistryServer_pb2.ListFeatureViewsRequest(
101+
grpc_handler.ListAllFeatureViews,
102+
RegistryServer_pb2.ListAllFeatureViewsRequest(
103103
project=project_name, allow_cache=allow_cache
104104
),
105105
)

sdk/python/tests/unit/api/test_api_rest_registry.py

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,6 +1528,90 @@ def test_metrics_resource_counts_via_rest(fastapi_test_app):
15281528
assert isinstance(per_project["demo_project"], dict)
15291529

15301530

1531+
def test_feature_views_all_types_and_resource_counts_match(fastapi_test_app):
1532+
"""
1533+
Test that verifies:
1534+
1. All types of feature views (regular, on-demand, stream) are returned in /feature_views/all
1535+
2. The count from /metrics/resource_counts matches the count from /feature_views/all
1536+
"""
1537+
response_all = fastapi_test_app.get("/feature_views/all")
1538+
assert response_all.status_code == 200
1539+
data_all = response_all.json()
1540+
assert "featureViews" in data_all
1541+
1542+
feature_views = data_all["featureViews"]
1543+
1544+
# Count should include at least:
1545+
# - 3 regular feature views: user_profile, user_behavior, user_preferences
1546+
# - 1 on-demand feature view: test_on_demand_feature_view
1547+
assert len(feature_views) >= 4, (
1548+
f"Expected at least 4 feature views, got {len(feature_views)}"
1549+
)
1550+
1551+
# Verify we have different types of feature views
1552+
feature_view_names = {fv["spec"]["name"] for fv in feature_views}
1553+
1554+
# Check for regular feature views
1555+
assert "user_profile" in feature_view_names, (
1556+
"Regular feature view 'user_profile' not found"
1557+
)
1558+
assert "user_behavior" in feature_view_names, (
1559+
"Regular feature view 'user_behavior' not found"
1560+
)
1561+
assert "user_preferences" in feature_view_names, (
1562+
"Regular feature view 'user_preferences' not found"
1563+
)
1564+
1565+
# Check for on-demand feature view
1566+
assert "test_on_demand_feature_view" in feature_view_names, (
1567+
"On-demand feature view 'test_on_demand_feature_view' not found"
1568+
)
1569+
1570+
# Verify all have the correct project
1571+
for fv in feature_views:
1572+
assert fv["project"] == "demo_project", (
1573+
f"Feature view has incorrect project: {fv.get('project')}"
1574+
)
1575+
1576+
# Now get resource counts from /metrics/resource_counts endpoint
1577+
response_metrics = fastapi_test_app.get(
1578+
"/metrics/resource_counts?project=demo_project"
1579+
)
1580+
assert response_metrics.status_code == 200
1581+
data_metrics = response_metrics.json()
1582+
assert "counts" in data_metrics
1583+
1584+
counts = data_metrics["counts"]
1585+
assert "featureViews" in counts
1586+
1587+
# Verify that the count from metrics matches the count from feature_views/all
1588+
feature_views_count_from_all = len(feature_views)
1589+
feature_views_count_from_metrics = counts["featureViews"]
1590+
1591+
assert feature_views_count_from_all == feature_views_count_from_metrics, (
1592+
f"Feature views count mismatch: /feature_views/all returned {feature_views_count_from_all} "
1593+
f"but /metrics/resource_counts returned {feature_views_count_from_metrics}"
1594+
)
1595+
1596+
# Test without project parameter (all projects)
1597+
response_all_projects = fastapi_test_app.get("/feature_views/all")
1598+
assert response_all_projects.status_code == 200
1599+
data_all_projects = response_all_projects.json()
1600+
1601+
response_metrics_all = fastapi_test_app.get("/metrics/resource_counts")
1602+
assert response_metrics_all.status_code == 200
1603+
data_metrics_all = response_metrics_all.json()
1604+
1605+
total_fv_count_from_all = len(data_all_projects["featureViews"])
1606+
total_fv_count_from_metrics = data_metrics_all["total"]["featureViews"]
1607+
1608+
assert total_fv_count_from_all == total_fv_count_from_metrics, (
1609+
f"Total feature views count mismatch across all projects: "
1610+
f"/feature_views/all returned {total_fv_count_from_all} "
1611+
f"but /metrics/resource_counts returned {total_fv_count_from_metrics}"
1612+
)
1613+
1614+
15311615
def test_metrics_recently_visited_via_rest(fastapi_test_app):
15321616
"""Test the /metrics/recently_visited endpoint."""
15331617
# First, make some requests to generate visit data

0 commit comments

Comments
 (0)