Build the projects list for the UI.
(
store: "feast.FeatureStore",
project_id: str,
root_path: str,
)
| 29 | |
| 30 | |
| 31 | def _build_projects_list( |
| 32 | store: "feast.FeatureStore", |
| 33 | project_id: str, |
| 34 | root_path: str, |
| 35 | ): |
| 36 | """Build the projects list for the UI.""" |
| 37 | discovered_projects = [] |
| 38 | registry_path_template = f"{root_path}/api/v1" |
| 39 | |
| 40 | try: |
| 41 | projects = store.registry.list_projects(allow_cache=True) |
| 42 | for proj in projects: |
| 43 | discovered_projects.append( |
| 44 | { |
| 45 | "name": proj.name.replace("_", " ").title(), |
| 46 | "description": proj.description or f"Project: {proj.name}", |
| 47 | "id": proj.name, |
| 48 | "registryPath": registry_path_template, |
| 49 | } |
| 50 | ) |
| 51 | except Exception: |
| 52 | pass |
| 53 | |
| 54 | if not discovered_projects: |
| 55 | discovered_projects.append( |
| 56 | { |
| 57 | "name": "Project", |
| 58 | "description": "Test project", |
| 59 | "id": project_id, |
| 60 | "registryPath": registry_path_template, |
| 61 | } |
| 62 | ) |
| 63 | |
| 64 | if len(discovered_projects) > 1: |
| 65 | all_projects_entry = { |
| 66 | "name": "All Projects", |
| 67 | "description": "View data across all projects", |
| 68 | "id": "all", |
| 69 | "registryPath": registry_path_template, |
| 70 | } |
| 71 | discovered_projects.insert(0, all_projects_entry) |
| 72 | |
| 73 | return {"projects": discovered_projects} |
| 74 | |
| 75 | |
| 76 | def _setup_rest_mode(app: FastAPI, store: "feast.FeatureStore"): |
no test coverage detected