1
+ import warnings
1
2
from typing import Callable , Dict , Iterable , Optional , Tuple
2
3
3
4
from pyarrow ._fs import FileSystem
@@ -61,6 +62,7 @@ def __init__(
61
62
self .file_options = FileOptions (
62
63
file_format = file_format ,
63
64
file_url = path ,
65
+ uri = path ,
64
66
s3_endpoint_override = s3_endpoint_override ,
65
67
)
66
68
@@ -85,7 +87,6 @@ def __eq__(self, other):
85
87
86
88
return (
87
89
self .name == other .name
88
- and self .file_options .file_url == other .file_options .file_url
89
90
and self .file_options .file_format == other .file_options .file_format
90
91
and self .event_timestamp_column == other .event_timestamp_column
91
92
and self .created_timestamp_column == other .created_timestamp_column
@@ -102,15 +103,15 @@ def path(self):
102
103
"""
103
104
Returns the path of this file data source.
104
105
"""
105
- return self .file_options .file_url
106
+ return self .file_options .uri
106
107
107
108
@staticmethod
108
109
def from_proto (data_source : DataSourceProto ):
109
110
return FileSource (
110
111
name = data_source .name ,
111
112
field_mapping = dict (data_source .field_mapping ),
112
113
file_format = FileFormat .from_proto (data_source .file_options .file_format ),
113
- path = data_source .file_options .file_url ,
114
+ path = data_source .file_options .uri ,
114
115
event_timestamp_column = data_source .event_timestamp_column ,
115
116
created_timestamp_column = data_source .created_timestamp_column ,
116
117
date_partition_column = data_source .date_partition_column ,
@@ -182,17 +183,28 @@ def __init__(
182
183
file_format : Optional [FileFormat ],
183
184
file_url : Optional [str ],
184
185
s3_endpoint_override : Optional [str ],
186
+ uri : Optional [str ],
185
187
):
186
188
"""
187
189
FileOptions initialization method
188
190
189
191
Args:
190
192
file_format (FileFormat, optional): file source format eg. parquet
191
- file_url (str, optional): file source url eg. s3:// or local file
192
- s3_endpoint_override (str, optional): custom s3 endpoint (used only with s3 file_url)
193
+ file_url (str, optional): [DEPRECATED] file source url eg. s3:// or local file
194
+ s3_endpoint_override (str, optional): custom s3 endpoint (used only with s3 uri)
195
+ uri (str, optional): file source url eg. s3:// or local file
196
+
193
197
"""
194
198
self ._file_format = file_format
195
- self ._file_url = file_url
199
+ if file_url :
200
+ warnings .warn (
201
+ (
202
+ "The option to pass a file_url parameter to FileOptions is being deprecated. "
203
+ "Please pass the file url to the uri parameter instead. The parameter will be deprecated in Feast 0.23"
204
+ ),
205
+ DeprecationWarning ,
206
+ )
207
+ self ._uri = uri or file_url
196
208
self ._s3_endpoint_override = s3_endpoint_override
197
209
198
210
@property
@@ -223,6 +235,20 @@ def file_url(self, file_url):
223
235
"""
224
236
self ._file_url = file_url
225
237
238
+ @property
239
+ def uri (self ):
240
+ """
241
+ Returns the file url of this file
242
+ """
243
+ return self ._uri
244
+
245
+ @uri .setter
246
+ def uri (self , uri ):
247
+ """
248
+ Sets the file url of this file
249
+ """
250
+ self ._uri = uri
251
+
226
252
@property
227
253
def s3_endpoint_override (self ):
228
254
"""
@@ -250,7 +276,8 @@ def from_proto(cls, file_options_proto: DataSourceProto.FileOptions):
250
276
"""
251
277
file_options = cls (
252
278
file_format = FileFormat .from_proto (file_options_proto .file_format ),
253
- file_url = file_options_proto .file_url ,
279
+ file_url = "" ,
280
+ uri = file_options_proto .uri ,
254
281
s3_endpoint_override = file_options_proto .s3_endpoint_override ,
255
282
)
256
283
return file_options
@@ -262,12 +289,11 @@ def to_proto(self) -> DataSourceProto.FileOptions:
262
289
Returns:
263
290
FileOptionsProto protobuf
264
291
"""
265
-
266
292
file_options_proto = DataSourceProto .FileOptions (
267
293
file_format = (
268
294
None if self .file_format is None else self .file_format .to_proto ()
269
295
),
270
- file_url = self .file_url ,
296
+ uri = self .uri ,
271
297
s3_endpoint_override = self .s3_endpoint_override ,
272
298
)
273
299
@@ -286,16 +312,17 @@ def __init__(
286
312
s3_endpoint_override : Optional [str ] = None ,
287
313
):
288
314
self .file_options = FileOptions (
289
- file_url = path ,
290
315
file_format = file_format ,
316
+ file_url = "" ,
291
317
s3_endpoint_override = s3_endpoint_override ,
318
+ uri = path ,
292
319
)
293
320
294
321
@staticmethod
295
322
def from_proto (storage_proto : SavedDatasetStorageProto ) -> SavedDatasetStorage :
296
323
file_options = FileOptions .from_proto (storage_proto .file_storage )
297
324
return SavedDatasetFileStorage (
298
- path = file_options .file_url ,
325
+ path = file_options .uri ,
299
326
file_format = file_options .file_format ,
300
327
s3_endpoint_override = file_options .s3_endpoint_override ,
301
328
)
@@ -305,7 +332,7 @@ def to_proto(self) -> SavedDatasetStorageProto:
305
332
306
333
def to_data_source (self ) -> DataSource :
307
334
return FileSource (
308
- path = self .file_options .file_url ,
335
+ path = self .file_options .uri ,
309
336
file_format = self .file_options .file_format ,
310
337
s3_endpoint_override = self .file_options .s3_endpoint_override ,
311
338
)
0 commit comments