1
- from typing import ByteString , Optional , overload , TYPE_CHECKING
1
+ from typing import ByteString , TYPE_CHECKING
2
+ import warnings
2
3
3
4
import tiledb .cc as lt
4
5
from .ctx import default_ctx
@@ -138,79 +139,12 @@ def copy_to(filestore_array_uri: str, file_uri: str, ctx: "Ctx" = None) -> None:
138
139
139
140
lt .Filestore ._uri_export (lt .Context (ctx , False ), filestore_array_uri , file_uri )
140
141
141
- def uri_import (self , uri : str , mime_type : str = "AUTODETECT" ) -> None :
142
- """
143
- :param int offset: Byte position to begin reading. Defaults to beginning of filestore.
144
- :param int size: Total number of bytes to read. Defaults to -1 which reads the entire filestore.
145
- :rtype: bytes
146
- :return: Data from the Filestore Array
147
-
148
- """
149
- try :
150
- buffer = memoryview (buffer )
151
- except TypeError :
152
- raise TypeError (
153
- f"Unexpected buffer type: buffer must support buffer protocol"
154
- )
155
-
156
- if not isinstance (mime_type , str ):
157
- raise TypeError (
158
- f"Unexpected mime_type type '{ type (mime_type )} ': expected str"
159
- )
160
-
161
- lt .Filestore ._buffer_import (
162
- lt .Context (self ._ctx , False ),
163
- self ._filestore_uri ,
164
- offset ,
165
- size ,
142
+ def uri_import (self , file_uri : str , mime_type : str = "AUTODETECT" ) -> None :
143
+ warnings .warn (
144
+ "Filestore.uri_import is deprecated; please use Filestore.copy_from" ,
145
+ DeprecationWarning ,
166
146
)
167
147
168
- def read (self , offset : int = 0 , size : int = - 1 ) -> bytes :
169
- """
170
- :param int offset: Byte position to begin reading. Defaults to beginning of filestore.
171
- :param int size: Total number of bytes to read. Defaults to -1 which reads the entire filestore.
172
- :rtype: bytes
173
- :return: Data from the Filestore Array
174
-
175
- """
176
- if not isinstance (offset , int ):
177
- raise TypeError (f"Unexpected offset type '{ type (offset )} ': expected int" )
178
-
179
- if not isinstance (size , int ):
180
- raise TypeError (f"Unexpected size type '{ type (size )} ': expected int" )
181
-
182
- if size == - 1 :
183
- size = len (self )
184
- size = max (size - offset , 0 )
185
-
186
- return lt .Filestore ._buffer_export (
187
- lt .Context (self ._ctx , False ),
188
- self ._filestore_uri ,
189
- offset ,
190
- size ,
191
- )
192
-
193
- @staticmethod
194
- def copy_from (
195
- filestore_array_uri : str ,
196
- file_uri : str ,
197
- mime_type : str = "AUTODETECT" ,
198
- ctx : "Ctx" = None ,
199
- ) -> None :
200
- """
201
- Copy data from a file to a Filestore Array.
202
-
203
- :param str filestore_array_uri: The URI to the TileDB Fileshare Array
204
- :param str file_uri: URI of file to export
205
- :param str mime_type: MIME types are "AUTODETECT" (default), "image/tiff", "application/pdf"
206
- :param tiledb.Ctx ctx: A TileDB context
207
-
208
- """
209
- if not isinstance (filestore_array_uri , str ):
210
- raise TypeError (
211
- f"Unexpected filestore_array_uri type '{ type (filestore_array_uri )} ': expected str"
212
- )
213
-
214
148
if not isinstance (file_uri , str ):
215
149
raise TypeError (
216
150
f"Unexpected file_uri type '{ type (file_uri )} ': expected str"
@@ -221,91 +155,13 @@ def copy_from(
221
155
f"Unexpected mime_type type '{ type (mime_type )} ': expected str"
222
156
)
223
157
224
- ctx = ctx or default_ctx ()
225
-
226
158
lt .Filestore ._uri_import (
227
- lt .Context (ctx , False ),
228
- filestore_array_uri ,
229
- file_uri ,
230
- lt .Filestore ._mime_type_from_str (mime_type ),
231
- )
232
-
233
- @staticmethod
234
- def copy_to (filestore_array_uri : str , file_uri : str , ctx : "Ctx" = None ) -> None :
235
- """
236
- Copy data from a Filestore Array to a file.
237
-
238
- :param str filestore_array_uri: The URI to the TileDB Fileshare Array
239
- :param str file_uri: The URI to the TileDB Fileshare Array
240
- :param tiledb.Ctx ctx: A TileDB context
241
-
242
- """
243
- if not isinstance (filestore_array_uri , str ):
244
- raise TypeError (
245
- f"Unexpected filestore_array_uri type '{ type (filestore_array_uri )} ': expected str"
246
- )
247
-
248
- if not isinstance (file_uri , str ):
249
- raise TypeError (
250
- f"Unexpected file_uri type '{ type (file_uri )} ': expected str"
251
- )
252
-
253
- ctx = ctx or default_ctx ()
254
-
255
- lt .Filestore ._uri_export (lt .Context (ctx , False ), filestore_array_uri , file_uri )
256
-
257
- def uri_import (self , uri : str , mime_type : str = "AUTODETECT" ) -> None :
258
- """
259
- Import data from an object that supports the buffer protocol to a Filestore Array.
260
-
261
- :param buffer ByteString: Data of type bytes, bytearray, memoryview, etc.
262
- :param str mime_type: MIME types are "AUTODETECT" (default), "image/tiff", "application/pdf"
263
-
264
- """
265
- try :
266
- buffer = memoryview (buffer )
267
- except TypeError :
268
- raise TypeError (
269
- f"Unexpected buffer type: buffer must support buffer protocol"
270
- )
271
-
272
- if not isinstance (mime_type , str ):
273
- raise TypeError (
274
- f"Unexpected mime_type type '{ type (mime_type )} ': expected str"
275
- )
276
-
277
- lt .Filestore ._buffer_import (
278
159
lt .Context (self ._ctx , False ),
279
160
self ._filestore_uri ,
280
- buffer ,
161
+ file_uri ,
281
162
lt .Filestore ._mime_type_from_str (mime_type ),
282
163
)
283
164
284
- def read (self , offset : int = 0 , size : int = - 1 ) -> bytes :
285
- """
286
- :param int offset: Byte position to begin reading. Defaults to beginning of filestore.
287
- :param int size: Total number of bytes to read. Defaults to -1 which reads the entire filestore.
288
- :rtype: bytes
289
- :return: Data from the Filestore Array
290
-
291
- """
292
- if not isinstance (offset , int ):
293
- raise TypeError (f"Unexpected offset type '{ type (offset )} ': expected int" )
294
-
295
- if not isinstance (size , int ):
296
- raise TypeError (f"Unexpected size type '{ type (size )} ': expected int" )
297
-
298
- if size == - 1 :
299
- size = len (self )
300
- size = max (size - offset , 0 )
301
-
302
- return lt .Filestore ._buffer_export (
303
- lt .Context (self ._ctx , False ),
304
- self ._filestore_uri ,
305
- offset ,
306
- size ,
307
- )
308
-
309
165
def __len__ (self ) -> int :
310
166
"""
311
167
:rtype: int
0 commit comments