Skip to content

Commit c4b6fbe

Browse files
authored
feat: Support pagination and sorting on registry apis (feast-dev#5495)
Signed-off-by: ntkathole <[email protected]>
1 parent 35f211c commit c4b6fbe

File tree

14 files changed

+1584
-386
lines changed

14 files changed

+1584
-386
lines changed

protos/feast/registry/RegistryServer.proto

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,26 @@ service RegistryServer{
9494

9595
}
9696

97+
// Common pagination and sorting messages
98+
message PaginationParams {
99+
int32 page = 1; // 1-based page number
100+
int32 limit = 2; // Number of items per page
101+
}
102+
103+
message SortingParams {
104+
string sort_by = 1; // Field to sort by (supports dot notation)
105+
string sort_order = 2; // "asc" or "desc"
106+
}
107+
108+
message PaginationMetadata {
109+
int32 page = 1;
110+
int32 limit = 2;
111+
int32 total_count = 3;
112+
int32 total_pages = 4;
113+
bool has_next = 5;
114+
bool has_previous = 6;
115+
}
116+
97117
message RefreshRequest {
98118
string project = 1;
99119
}
@@ -142,10 +162,13 @@ message ListEntitiesRequest {
142162
string project = 1;
143163
bool allow_cache = 2;
144164
map<string,string> tags = 3;
165+
PaginationParams pagination = 4;
166+
SortingParams sorting = 5;
145167
}
146168

147169
message ListEntitiesResponse {
148170
repeated feast.core.Entity entities = 1;
171+
PaginationMetadata pagination = 2;
149172
}
150173

151174
message DeleteEntityRequest {
@@ -172,10 +195,13 @@ message ListDataSourcesRequest {
172195
string project = 1;
173196
bool allow_cache = 2;
174197
map<string,string> tags = 3;
198+
PaginationParams pagination = 4;
199+
SortingParams sorting = 5;
175200
}
176201

177202
message ListDataSourcesResponse {
178203
repeated feast.core.DataSource data_sources = 1;
204+
PaginationMetadata pagination = 2;
179205
}
180206

181207
message DeleteDataSourceRequest {
@@ -206,10 +232,13 @@ message ListFeatureViewsRequest {
206232
string project = 1;
207233
bool allow_cache = 2;
208234
map<string,string> tags = 3;
235+
PaginationParams pagination = 4;
236+
SortingParams sorting = 5;
209237
}
210238

211239
message ListFeatureViewsResponse {
212240
repeated feast.core.FeatureView feature_views = 1;
241+
PaginationMetadata pagination = 2;
213242
}
214243

215244
message DeleteFeatureViewRequest {
@@ -240,10 +269,13 @@ message ListAllFeatureViewsRequest {
240269
string project = 1;
241270
bool allow_cache = 2;
242271
map<string,string> tags = 3;
272+
PaginationParams pagination = 4;
273+
SortingParams sorting = 5;
243274
}
244275

245276
message ListAllFeatureViewsResponse {
246277
repeated AnyFeatureView feature_views = 1;
278+
PaginationMetadata pagination = 2;
247279
}
248280

249281

@@ -259,10 +291,13 @@ message ListStreamFeatureViewsRequest {
259291
string project = 1;
260292
bool allow_cache = 2;
261293
map<string,string> tags = 3;
294+
PaginationParams pagination = 4;
295+
SortingParams sorting = 5;
262296
}
263297

264298
message ListStreamFeatureViewsResponse {
265299
repeated feast.core.StreamFeatureView stream_feature_views = 1;
300+
PaginationMetadata pagination = 2;
266301
}
267302

268303
// OnDemandFeatureView
@@ -277,10 +312,13 @@ message ListOnDemandFeatureViewsRequest {
277312
string project = 1;
278313
bool allow_cache = 2;
279314
map<string,string> tags = 3;
315+
PaginationParams pagination = 4;
316+
SortingParams sorting = 5;
280317
}
281318

282319
message ListOnDemandFeatureViewsResponse {
283320
repeated feast.core.OnDemandFeatureView on_demand_feature_views = 1;
321+
PaginationMetadata pagination = 2;
284322
}
285323

286324
// FeatureServices
@@ -301,10 +339,13 @@ message ListFeatureServicesRequest {
301339
string project = 1;
302340
bool allow_cache = 2;
303341
map<string,string> tags = 3;
342+
PaginationParams pagination = 4;
343+
SortingParams sorting = 5;
304344
}
305345

306346
message ListFeatureServicesResponse {
307347
repeated feast.core.FeatureService feature_services = 1;
348+
PaginationMetadata pagination = 2;
308349
}
309350

310351
message DeleteFeatureServiceRequest {
@@ -331,10 +372,13 @@ message ListSavedDatasetsRequest {
331372
string project = 1;
332373
bool allow_cache = 2;
333374
map<string,string> tags = 3;
375+
PaginationParams pagination = 4;
376+
SortingParams sorting = 5;
334377
}
335378

336379
message ListSavedDatasetsResponse {
337380
repeated feast.core.SavedDataset saved_datasets = 1;
381+
PaginationMetadata pagination = 2;
338382
}
339383

340384
message DeleteSavedDatasetRequest {
@@ -361,10 +405,13 @@ message ListValidationReferencesRequest {
361405
string project = 1;
362406
bool allow_cache = 2;
363407
map<string,string> tags = 3;
408+
PaginationParams pagination = 4;
409+
SortingParams sorting = 5;
364410
}
365411

366412
message ListValidationReferencesResponse {
367413
repeated feast.core.ValidationReference validation_references = 1;
414+
PaginationMetadata pagination = 2;
368415
}
369416

370417
message DeleteValidationReferenceRequest {
@@ -391,10 +438,13 @@ message ListPermissionsRequest {
391438
string project = 1;
392439
bool allow_cache = 2;
393440
map<string,string> tags = 3;
441+
PaginationParams pagination = 4;
442+
SortingParams sorting = 5;
394443
}
395444

396445
message ListPermissionsResponse {
397446
repeated feast.core.Permission permissions = 1;
447+
PaginationMetadata pagination = 2;
398448
}
399449

400450
message DeletePermissionRequest {
@@ -418,10 +468,13 @@ message GetProjectRequest {
418468
message ListProjectsRequest {
419469
bool allow_cache = 1;
420470
map<string,string> tags = 2;
471+
PaginationParams pagination = 3;
472+
SortingParams sorting = 4;
421473
}
422474

423475
message ListProjectsResponse {
424476
repeated feast.core.Project projects = 1;
477+
PaginationMetadata pagination = 2;
425478
}
426479

427480
message DeleteProjectRequest {
@@ -446,11 +499,15 @@ message GetRegistryLineageRequest {
446499
bool allow_cache = 2;
447500
string filter_object_type = 3;
448501
string filter_object_name = 4;
502+
PaginationParams pagination = 5;
503+
SortingParams sorting = 6;
449504
}
450505

451506
message GetRegistryLineageResponse {
452507
repeated EntityRelation relationships = 1;
453508
repeated EntityRelation indirect_relationships = 2;
509+
PaginationMetadata relationships_pagination = 3;
510+
PaginationMetadata indirect_relationships_pagination = 4;
454511
}
455512

456513
message GetObjectRelationshipsRequest {
@@ -459,8 +516,11 @@ message GetObjectRelationshipsRequest {
459516
string object_name = 3;
460517
bool include_indirect = 4;
461518
bool allow_cache = 5;
519+
PaginationParams pagination = 6;
520+
SortingParams sorting = 7;
462521
}
463522

464523
message GetObjectRelationshipsResponse {
465524
repeated EntityRelation relationships = 1;
525+
PaginationMetadata pagination = 2;
466526
}

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33

44
from fastapi import APIRouter, Depends, Query
55

6-
from feast.api.registry.rest.rest_utils import grpc_call, parse_tags
6+
from feast.api.registry.rest.rest_utils import (
7+
create_grpc_pagination_params,
8+
create_grpc_sorting_params,
9+
get_pagination_params,
10+
get_sorting_params,
11+
grpc_call,
12+
parse_tags,
13+
)
714
from feast.protos.feast.registry import RegistryServer_pb2
815

916
logger = logging.getLogger(__name__)
@@ -17,14 +24,22 @@ def list_data_sources(
1724
project: str = Query(...),
1825
allow_cache: bool = Query(default=True),
1926
tags: Dict[str, str] = Depends(parse_tags),
27+
pagination_params: dict = Depends(get_pagination_params),
28+
sorting_params: dict = Depends(get_sorting_params),
2029
):
2130
req = RegistryServer_pb2.ListDataSourcesRequest(
2231
project=project,
2332
allow_cache=allow_cache,
2433
tags=tags,
34+
pagination=create_grpc_pagination_params(pagination_params),
35+
sorting=create_grpc_sorting_params(sorting_params),
2536
)
37+
2638
response = grpc_call(grpc_handler.ListDataSources, req)
27-
return {"data_sources": response.get("dataSources", [])}
39+
return {
40+
"data_sources": response.get("dataSources", []),
41+
"pagination": response.get("pagination", {}),
42+
}
2843

2944
@router.get("/data_sources/{name}")
3045
def get_data_source(

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import logging
22

3-
from fastapi import APIRouter, Query
4-
5-
from feast.api.registry.rest.rest_utils import grpc_call
3+
from fastapi import APIRouter, Depends, Query
4+
5+
from feast.api.registry.rest.rest_utils import (
6+
create_grpc_pagination_params,
7+
create_grpc_sorting_params,
8+
get_pagination_params,
9+
get_sorting_params,
10+
grpc_call,
11+
)
612
from feast.protos.feast.registry import RegistryServer_pb2
713

814
logger = logging.getLogger(__name__)
@@ -14,10 +20,18 @@ def get_entity_router(grpc_handler) -> APIRouter:
1420
@router.get("/entities")
1521
def list_entities(
1622
project: str = Query(...),
23+
allow_cache: bool = Query(default=True),
24+
pagination_params: dict = Depends(get_pagination_params),
25+
sorting_params: dict = Depends(get_sorting_params),
1726
):
18-
req = RegistryServer_pb2.ListEntitiesRequest(project=project)
19-
response = grpc_call(grpc_handler.ListEntities, req)
20-
return {"entities": response.get("entities", [])}
27+
req = RegistryServer_pb2.ListEntitiesRequest(
28+
project=project,
29+
allow_cache=allow_cache,
30+
pagination=create_grpc_pagination_params(pagination_params),
31+
sorting=create_grpc_sorting_params(sorting_params),
32+
)
33+
34+
return grpc_call(grpc_handler.ListEntities, req)
2135

2236
@router.get("/entities/{name}")
2337
def get_entity(

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
from fastapi import APIRouter, Depends, Query
44

5-
from feast.api.registry.rest.rest_utils import grpc_call, parse_tags
5+
from feast.api.registry.rest.rest_utils import (
6+
create_grpc_pagination_params,
7+
create_grpc_sorting_params,
8+
get_pagination_params,
9+
get_sorting_params,
10+
grpc_call,
11+
parse_tags,
12+
)
613
from feast.protos.feast.registry import RegistryServer_pb2
714

815

@@ -14,11 +21,15 @@ def list_feature_services(
1421
project: str = Query(...),
1522
allow_cache: bool = Query(default=True),
1623
tags: Dict[str, str] = Depends(parse_tags),
24+
pagination_params: dict = Depends(get_pagination_params),
25+
sorting_params: dict = Depends(get_sorting_params),
1726
):
1827
req = RegistryServer_pb2.ListFeatureServicesRequest(
1928
project=project,
2029
allow_cache=allow_cache,
2130
tags=tags,
31+
pagination=create_grpc_pagination_params(pagination_params),
32+
sorting=create_grpc_sorting_params(sorting_params),
2233
)
2334
return grpc_call(grpc_handler.ListFeatureServices, req)
2435

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,14 @@
22

33
from fastapi import APIRouter, Depends, Query
44

5-
from feast.api.registry.rest.rest_utils import grpc_call, parse_tags
5+
from feast.api.registry.rest.rest_utils import (
6+
create_grpc_pagination_params,
7+
create_grpc_sorting_params,
8+
get_pagination_params,
9+
get_sorting_params,
10+
grpc_call,
11+
parse_tags,
12+
)
613
from feast.registry_server import RegistryServer_pb2
714

815

@@ -21,18 +28,29 @@ def get_any_feature_view(
2128
allow_cache=allow_cache,
2229
)
2330
response = grpc_call(grpc_handler.GetAnyFeatureView, req)
24-
return response.get("anyFeatureView", {})
31+
any_feature_view = response.get("anyFeatureView", {})
32+
feature_view = (
33+
any_feature_view.get("featureView")
34+
or any_feature_view.get("onDemandFeatureView")
35+
or any_feature_view.get("streamFeatureView")
36+
or {}
37+
)
38+
return {"featureView": feature_view}
2539

2640
@router.get("/feature_views")
2741
def list_all_feature_views(
2842
project: str = Query(...),
29-
allow_cache: bool = Query(True),
43+
allow_cache: bool = Query(default=True),
3044
tags: Dict[str, str] = Depends(parse_tags),
45+
pagination_params: dict = Depends(get_pagination_params),
46+
sorting_params: dict = Depends(get_sorting_params),
3147
):
3248
req = RegistryServer_pb2.ListAllFeatureViewsRequest(
3349
project=project,
3450
allow_cache=allow_cache,
3551
tags=tags,
52+
pagination=create_grpc_pagination_params(pagination_params),
53+
sorting=create_grpc_sorting_params(sorting_params),
3654
)
3755
return grpc_call(grpc_handler.ListAllFeatureViews, req)
3856

0 commit comments

Comments
 (0)