This repository has been archived by the owner on Sep 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathabstract_bucketfs_location.py
102 lines (85 loc) · 2.68 KB
/
abstract_bucketfs_location.py
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
from abc import ABC, abstractmethod, ABCMeta
from typing import Any, Tuple, IO, Iterable, Optional
from pathlib import PurePosixPath, Path
from urllib.parse import ParseResult
from typing import Union
class AbstractBucketFSLocation(ABC, metaclass=ABCMeta):
"""
Abstract class for a BucketFSLocation for uploading and downloading strings,
fileobjects and joblib objects. Also able to read files from the BucketFS
directly, if called from inside a UDF.
"""
@abstractmethod
def generate_bucket_udf_path(
self, path_in_bucket: Optional[Union[str, PurePosixPath]]=None) \
-> PurePosixPath:
pass
@abstractmethod
def get_complete_file_path_in_bucket(
self, bucket_file_path: Optional[Union[str, PurePosixPath]]=None) -> str:
pass
@abstractmethod
def download_from_bucketfs_to_string(
self,
bucket_file_path: str) -> str:
pass
@abstractmethod
def download_object_from_bucketfs_via_joblib(
self,
bucket_file_path: str) -> Any:
pass
@abstractmethod
def upload_string_to_bucketfs(
self,
bucket_file_path: str,
string: str) -> Tuple[ParseResult, PurePosixPath]:
pass
@abstractmethod
def upload_object_to_bucketfs_via_joblib(
self,
object: Any,
bucket_file_path: str,
**kwargs) -> Tuple[ParseResult, PurePosixPath]:
pass
@abstractmethod
def upload_fileobj_to_bucketfs(
self,
fileobj: IO,
bucket_file_path: str) -> Tuple[ParseResult, PurePosixPath]:
pass
# TODO add missing upload/download functions
@abstractmethod
def read_file_from_bucketfs_to_string(
self,
bucket_file_path: str) -> str:
pass
@abstractmethod
def read_file_from_bucketfs_to_file(
self,
bucket_file_path: str,
local_file_path: Path) -> None:
pass
@abstractmethod
def read_file_from_bucketfs_to_fileobj(
self,
bucket_file_path: str,
fileobj: IO) -> None:
pass
@abstractmethod
def read_file_from_bucketfs_via_joblib(
self,
bucket_file_path: str) -> Any:
pass
@abstractmethod
def list_files_in_bucketfs(
self,
bucket_file_path: str) -> Iterable[str]:
pass
@abstractmethod
def delete_file_in_bucketfs(
self,
bucket_file_path: str) -> None:
pass
@abstractmethod
def joinpath(self, *others: Union[str, PurePosixPath]) -> "AbstractBucketFSLocation":
pass