forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodels.py
More file actions
154 lines (113 loc) · 4.59 KB
/
Copy pathmodels.py
File metadata and controls
154 lines (113 loc) · 4.59 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
"""
Pydantic models matching the Iceberg REST Catalog API response shapes.
Reference: https://github.com/apache/iceberg/blob/main/open-api/rest-catalog-open-api.yaml
These models define the API contract for the Catalog API. They are intentionally
Iceberg-shaped — even for asset types that Feast or the supplemental store manage
internally — so that the API surface follows the standard regardless of backend.
Target location in Feast repo: sdk/python/feast/api/catalog/models.py
"""
from __future__ import annotations
from enum import Enum
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field
# --- Iceberg Namespace models ---
class CreateNamespaceRequest(BaseModel):
namespace: List[str] = Field(
...,
description="Multi-level namespace identifier",
json_schema_extra={"example": ["underwriting"]},
)
properties: Dict[str, str] = Field(
default_factory=dict,
description="Key-value properties for the namespace",
json_schema_extra={
"example": {"owner": "data-team", "domain": "property-casualty"}
},
)
class NamespaceResponse(BaseModel):
namespace: List[str] = Field(
..., description="Multi-level namespace identifier"
)
properties: Dict[str, str] = Field(default_factory=dict)
class ListNamespacesResponse(BaseModel):
model_config = {"populate_by_name": True}
namespaces: List[List[str]] = Field(
..., description="List of namespace identifiers"
)
next_page_token: Optional[str] = Field(
None,
alias="next-page-token",
description="Opaque token for next page, null if no more pages",
)
# --- Iceberg Table models ---
class TableIdentifier(BaseModel):
namespace: List[str] = Field(..., description="Namespace the table belongs to")
name: str = Field(..., description="Table name")
class Schema(BaseModel):
model_config = {"populate_by_name": True}
type: str = Field(default="struct")
schema_id: int = Field(default=0, alias="schema-id")
fields: List[Dict[str, Any]] = Field(default_factory=list)
class TableMetadata(BaseModel):
model_config = {"populate_by_name": True}
format_version: int = Field(default=2, alias="format-version")
table_uuid: str = Field(..., alias="table-uuid")
location: str = Field(..., description="Storage location URI")
schemas: List[Schema] = Field(default_factory=list)
current_schema_id: int = Field(default=0, alias="current-schema-id")
properties: Dict[str, str] = Field(default_factory=dict)
class AssetType(str, Enum):
"""Catalog asset types — extends Iceberg's table concept to non-tabular assets."""
TABLE = "table"
FEATURE_VIEW = "feature_view"
DATA_SOURCE = "data_source"
DOCUMENT_COLLECTION = "document_collection"
VECTOR_INDEX = "vector_index"
DATASET = "dataset"
class CreateTableRequest(BaseModel):
model_config = {"populate_by_name": True}
name: str = Field(..., description="Table name")
schema_: Optional[Schema] = Field(None, alias="schema")
location: Optional[str] = Field(
None, description="Storage location URI (e.g., s3://, milvus://)"
)
properties: Dict[str, str] = Field(
default_factory=dict,
description="Arbitrary key-value properties",
json_schema_extra={
"example": {
"asset_type": "document_collection",
"domain": "property-casualty",
"doc_count": "10",
}
},
)
class LoadTableResult(BaseModel):
model_config = {"populate_by_name": True}
metadata_location: str = Field(
...,
alias="metadata-location",
description="Location of the table metadata",
)
metadata: TableMetadata = Field(...)
config: Dict[str, str] = Field(default_factory=dict)
class ListTablesResponse(BaseModel):
model_config = {"populate_by_name": True}
identifiers: List[TableIdentifier] = Field(
..., description="List of table identifiers in the namespace"
)
next_page_token: Optional[str] = Field(
None,
alias="next-page-token",
description="Opaque token for next page",
)
# --- Error model ---
class IcebergErrorResponse(BaseModel):
message: str = Field(..., description="Human-readable error message")
type: str = Field(
...,
description="Error type identifier",
json_schema_extra={"example": "NoSuchNamespaceException"},
)
code: int = Field(..., ge=400, lt=600, description="HTTP status code")
stack: Optional[List[str]] = Field(None, description="Stack trace (debug only)")