-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathsaved_datasets.py
More file actions
37 lines (31 loc) · 1.12 KB
/
saved_datasets.py
File metadata and controls
37 lines (31 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from fastapi import APIRouter, Depends, Query
from feast.api.registry.rest.rest_utils import grpc_call, parse_tags
from feast.protos.feast.registry import RegistryServer_pb2
def get_saved_dataset_router(grpc_handler) -> APIRouter:
router = APIRouter()
@router.get("/saved_datasets/{name}")
def get_saved_dataset(
name: str,
project: str = Query(...),
allow_cache: bool = Query(True),
):
req = RegistryServer_pb2.GetSavedDatasetRequest(
name=name,
project=project,
allow_cache=allow_cache,
)
return grpc_call(grpc_handler.GetSavedDataset, req)
@router.get("/saved_datasets")
def list_saved_datasets(
project: str = Query(...),
allow_cache: bool = Query(True),
tags: dict = Depends(parse_tags),
):
req = RegistryServer_pb2.ListSavedDatasetsRequest(
project=project,
allow_cache=allow_cache,
tags=tags,
)
response = grpc_call(grpc_handler.ListSavedDatasets, req)
return {"saved_datasets": response.get("saved_datasets", [])}
return router