forked from feast-dev/feast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremote.py
More file actions
344 lines (263 loc) · 11.1 KB
/
Copy pathremote.py
File metadata and controls
344 lines (263 loc) · 11.1 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
from datetime import datetime
from pathlib import Path
from typing import List, Optional, Union
import grpc
from google.protobuf.empty_pb2 import Empty
from pydantic import StrictStr
from feast.base_feature_view import BaseFeatureView
from feast.data_source import DataSource
from feast.entity import Entity
from feast.errors import ReadOnlyRegistryException
from feast.feature_service import FeatureService
from feast.feature_view import FeatureView
from feast.infra.infra_object import Infra
from feast.infra.registry.base_registry import BaseRegistry
from feast.on_demand_feature_view import OnDemandFeatureView
from feast.project_metadata import ProjectMetadata
from feast.protos.feast.core.Registry_pb2 import Registry as RegistryProto
from feast.protos.feast.registry import RegistryServer_pb2, RegistryServer_pb2_grpc
from feast.repo_config import RegistryConfig
from feast.saved_dataset import SavedDataset, ValidationReference
from feast.stream_feature_view import StreamFeatureView
class RemoteRegistryConfig(RegistryConfig):
registry_type: StrictStr = "remote"
""" str: Provider name or a class name that implements Registry."""
path: StrictStr = ""
""" str: Path to metadata store.
If registry_type is 'remote', then this is a URL for registry server """
class RemoteRegistry(BaseRegistry):
def __init__(
self,
registry_config: Union[RegistryConfig, RemoteRegistryConfig],
project: str,
repo_path: Optional[Path],
):
self.channel = grpc.insecure_channel(registry_config.path)
self.stub = RegistryServer_pb2_grpc.RegistryServerStub(self.channel)
def apply_entity(self, entity: Entity, project: str, commit: bool = True):
raise ReadOnlyRegistryException()
def delete_entity(self, name: str, project: str, commit: bool = True):
raise ReadOnlyRegistryException()
def get_entity(self, name: str, project: str, allow_cache: bool = False) -> Entity:
request = RegistryServer_pb2.GetEntityRequest(
name=name, project=project, allow_cache=allow_cache
)
response = self.stub.GetEntity(request)
return Entity.from_proto(response)
def list_entities(self, project: str, allow_cache: bool = False) -> List[Entity]:
request = RegistryServer_pb2.ListEntitiesRequest(
project=project, allow_cache=allow_cache
)
response = self.stub.ListEntities(request)
return [Entity.from_proto(entity) for entity in response.entities]
def apply_data_source(
self, data_source: DataSource, project: str, commit: bool = True
):
raise ReadOnlyRegistryException()
def delete_data_source(self, name: str, project: str, commit: bool = True):
raise ReadOnlyRegistryException()
def get_data_source(
self, name: str, project: str, allow_cache: bool = False
) -> DataSource:
request = RegistryServer_pb2.GetDataSourceRequest(
name=name, project=project, allow_cache=allow_cache
)
response = self.stub.GetDataSource(request)
return DataSource.from_proto(response)
def list_data_sources(
self, project: str, allow_cache: bool = False
) -> List[DataSource]:
request = RegistryServer_pb2.ListDataSourcesRequest(
project=project, allow_cache=allow_cache
)
response = self.stub.ListDataSources(request)
return [
DataSource.from_proto(data_source) for data_source in response.data_sources
]
def apply_feature_service(
self, feature_service: FeatureService, project: str, commit: bool = True
):
raise ReadOnlyRegistryException()
def delete_feature_service(self, name: str, project: str, commit: bool = True):
raise ReadOnlyRegistryException()
def get_feature_service(
self, name: str, project: str, allow_cache: bool = False
) -> FeatureService:
request = RegistryServer_pb2.GetFeatureServiceRequest(
name=name, project=project, allow_cache=allow_cache
)
response = self.stub.GetFeatureService(request)
return FeatureService.from_proto(response)
def list_feature_services(
self, project: str, allow_cache: bool = False
) -> List[FeatureService]:
request = RegistryServer_pb2.ListFeatureServicesRequest(
project=project, allow_cache=allow_cache
)
response = self.stub.ListFeatureServices(request)
return [
FeatureService.from_proto(feature_service)
for feature_service in response.feature_services
]
def apply_feature_view(
self, feature_view: BaseFeatureView, project: str, commit: bool = True
):
raise ReadOnlyRegistryException()
def delete_feature_view(self, name: str, project: str, commit: bool = True):
raise ReadOnlyRegistryException()
def get_stream_feature_view(
self, name: str, project: str, allow_cache: bool = False
) -> StreamFeatureView:
request = RegistryServer_pb2.GetStreamFeatureViewRequest(
name=name, project=project, allow_cache=allow_cache
)
response = self.stub.GetStreamFeatureView(request)
return StreamFeatureView.from_proto(response)
def list_stream_feature_views(
self, project: str, allow_cache: bool = False
) -> List[StreamFeatureView]:
request = RegistryServer_pb2.ListStreamFeatureViewsRequest(
project=project, allow_cache=allow_cache
)
response = self.stub.ListStreamFeatureViews(request)
return [
StreamFeatureView.from_proto(stream_feature_view)
for stream_feature_view in response.stream_feature_views
]
def get_on_demand_feature_view(
self, name: str, project: str, allow_cache: bool = False
) -> OnDemandFeatureView:
request = RegistryServer_pb2.GetOnDemandFeatureViewRequest(
name=name, project=project, allow_cache=allow_cache
)
response = self.stub.GetOnDemandFeatureView(request)
return OnDemandFeatureView.from_proto(response)
def list_on_demand_feature_views(
self, project: str, allow_cache: bool = False
) -> List[OnDemandFeatureView]:
request = RegistryServer_pb2.ListOnDemandFeatureViewsRequest(
project=project, allow_cache=allow_cache
)
response = self.stub.ListOnDemandFeatureViews(request)
return [
OnDemandFeatureView.from_proto(on_demand_feature_view)
for on_demand_feature_view in response.on_demand_feature_views
]
def get_feature_view(
self, name: str, project: str, allow_cache: bool = False
) -> FeatureView:
request = RegistryServer_pb2.GetFeatureViewRequest(
name=name, project=project, allow_cache=allow_cache
)
response = self.stub.GetFeatureView(request)
return FeatureView.from_proto(response)
def list_feature_views(
self, project: str, allow_cache: bool = False
) -> List[FeatureView]:
request = RegistryServer_pb2.ListFeatureViewsRequest(
project=project, allow_cache=allow_cache
)
response = self.stub.ListFeatureViews(request)
return [
FeatureView.from_proto(feature_view)
for feature_view in response.feature_views
]
def apply_materialization(
self,
feature_view: FeatureView,
project: str,
start_date: datetime,
end_date: datetime,
commit: bool = True,
):
raise ReadOnlyRegistryException()
def apply_saved_dataset(
self,
saved_dataset: SavedDataset,
project: str,
commit: bool = True,
):
raise ReadOnlyRegistryException()
def delete_saved_dataset(self, name: str, project: str, allow_cache: bool = False):
raise ReadOnlyRegistryException()
def get_saved_dataset(
self, name: str, project: str, allow_cache: bool = False
) -> SavedDataset:
request = RegistryServer_pb2.GetSavedDatasetRequest(
name=name, project=project, allow_cache=allow_cache
)
response = self.stub.GetSavedDataset(request)
return SavedDataset.from_proto(response)
def list_saved_datasets(
self, project: str, allow_cache: bool = False
) -> List[SavedDataset]:
request = RegistryServer_pb2.ListSavedDatasetsRequest(
project=project, allow_cache=allow_cache
)
response = self.stub.ListSavedDatasets(request)
return [
SavedDataset.from_proto(saved_dataset)
for saved_dataset in response.saved_datasets
]
def apply_validation_reference(
self,
validation_reference: ValidationReference,
project: str,
commit: bool = True,
):
raise ReadOnlyRegistryException()
def delete_validation_reference(self, name: str, project: str, commit: bool = True):
raise ReadOnlyRegistryException()
def get_validation_reference(
self, name: str, project: str, allow_cache: bool = False
) -> ValidationReference:
request = RegistryServer_pb2.GetValidationReferenceRequest(
name=name, project=project, allow_cache=allow_cache
)
response = self.stub.GetValidationReference(request)
return ValidationReference.from_proto(response)
def list_validation_references(
self, project: str, allow_cache: bool = False
) -> List[ValidationReference]:
request = RegistryServer_pb2.ListValidationReferencesRequest(
project=project, allow_cache=allow_cache
)
response = self.stub.ListValidationReferences(request)
return [
ValidationReference.from_proto(validation_reference)
for validation_reference in response.validation_references
]
def list_project_metadata(
self, project: str, allow_cache: bool = False
) -> List[ProjectMetadata]:
request = RegistryServer_pb2.ListProjectMetadataRequest(
project=project, allow_cache=allow_cache
)
response = self.stub.ListProjectMetadata(request)
return [ProjectMetadata.from_proto(pm) for pm in response.project_metadata]
def update_infra(self, infra: Infra, project: str, commit: bool = True):
raise ReadOnlyRegistryException()
def get_infra(self, project: str, allow_cache: bool = False) -> Infra:
request = RegistryServer_pb2.GetInfraRequest(
project=project, allow_cache=allow_cache
)
response = self.stub.GetInfra(request)
return Infra.from_proto(response)
def apply_user_metadata(
self,
project: str,
feature_view: BaseFeatureView,
metadata_bytes: Optional[bytes],
):
pass
def get_user_metadata(
self, project: str, feature_view: BaseFeatureView
) -> Optional[bytes]:
pass
def proto(self) -> RegistryProto:
return self.stub.Proto(Empty())
def commit(self):
raise ReadOnlyRegistryException()
def refresh(self, project: Optional[str] = None):
request = RegistryServer_pb2.RefreshRequest(project=str(project))
self.stub.Refresh(request)