forked from activeloopai/deeplake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexceptions.py
260 lines (169 loc) · 7.47 KB
/
exceptions.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
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
from click import ClickException
class OutOfBoundsError(Exception):
"""Raised upon finding a missing chunk."""
pass
class AlignmentError(Exception):
"""Raised when there is an Alignment error."""
pass
class IncompatibleShapes(Exception):
"""Shapes do not match"""
pass
class IncompatibleBroadcasting(Exception):
"""Broadcasting issue"""
pass
class IncompatibleTypes(Exception):
"""Types can not cast"""
pass
class WrongTypeError(Exception):
"""Types is not supported"""
pass
class NotAuthorized(Exception):
"""Types is not supported"""
pass
class NotFound(Exception):
"""When Info could not be found for array"""
pass
class FileSystemException(Exception):
"""Error working with local file system"""
pass
class S3Exception(Exception):
"""Error working with AWS"""
pass
class S3CredsParseException(Exception):
"""Can't parse AWS creds"""
pass
class HubException(ClickException):
def __init__(self, message=None, code=None):
super().__init__(message)
class AuthenticationException(HubException):
def __init__(self, message="Authentication failed. Please login again."):
super().__init__(message=message)
class AuthorizationException(HubException):
def __init__(self, response):
try:
message = response.json()["message"]
except (KeyError, AttributeError):
message = "You are not authorized to access this resource on Snark AI."
super().__init__(message=message)
class NotFoundException(HubException):
def __init__(
self,
message="The resource you are looking for was not found. Check if the name or id is correct.",
):
super().__init__(message=message)
class BadRequestException(HubException):
def __init__(self, response):
try:
message = "One or more request parameters is incorrect\n%s" % str(
response.json()["message"]
)
except (KeyError, AttributeError):
message = "One or more request parameters is incorrect, %s" % str(
response.content
)
super().__init__(message=message)
class OverLimitException(HubException):
def __init__(
self,
message="You are over the allowed limits for this operation. Consider upgrading your account.",
):
super().__init__(message=message)
class ServerException(HubException):
def __init__(self, message="Internal Snark AI server error."):
super().__init__(message=message)
class BadGatewayException(HubException):
def __init__(self, message="Invalid response from Snark AI server."):
super().__init__(message=message)
class GatewayTimeoutException(HubException):
def __init__(self, message="Snark AI server took too long to respond."):
super().__init__(message=message)
class WaitTimeoutException(HubException):
def __init__(self, message="Timeout waiting for server state update."):
super().__init__(message=message)
class LockedException(HubException):
def __init__(self, message="Resource locked."):
super().__init__(message=message)
class HubDatasetNotFoundException(HubException):
def __init__(self, response):
message = f"The dataset with tag {response} was not found"
super(HubDatasetNotFoundException, self).__init__(message=message)
class PermissionException(HubException):
def __init__(self, response):
message = f"No permision to store the dataset at {response}"
super(PermissionException, self).__init__(message=message)
class ShapeArgumentNotFoundException(HubException):
def __init__(self):
message = "Parameter 'shape' should be provided for Dataset creation."
super(HubException, self).__init__(message=message)
class SchemaArgumentNotFoundException(HubException):
def __init__(self):
message = "Parameter 'schema' should be provided for Dataset creation."
super(HubException, self).__init__(message=message)
class ValueShapeError(HubException):
def __init__(self, correct_shape, wrong_shape):
message = f"parameter 'value': expected array with shape {correct_shape}, got {wrong_shape}"
super(HubException, self).__init__(message=message)
class NoneValueException(HubException):
def __init__(self, param):
message = f"Parameter '{param}' should be provided"
super(HubException, self).__init__(message=message)
class ShapeLengthException(HubException):
def __init__(self):
message = "Parameter 'shape' should be a tuple of length 1"
super(HubException, self).__init__(message=message)
class ModuleNotInstalledException(HubException):
def __init__(self, module_name):
message = f"Module '{module_name}' should be installed to convert the Dataset to the {module_name} format"
super(HubException, self).__init__(message=message)
class DaskModuleNotInstalledException(HubException):
def __init__(self, message=""):
message = "Dask has been deprecated and made optional. Older versions of 0.x hub datasets require loading dask. Please install it: pip install 'dask[complete]>=2.30'"
super(HubException, self).__init__(message=message)
class WrongUsernameException(HubException):
def __init__(self, username):
message = (
f"Username {username} doesn't have access to the given url. Please check your permissions "
"or make sure that the username provided in the url matches the one used during login or ."
)
super(HubException, self).__init__(message=message)
class NotHubDatasetToOverwriteException(HubException):
def __init__(self):
message = (
"Unable to overwrite the dataset. "
"The provided directory is not empty and doesn't contain information about any Hub Dataset "
)
super(HubException, self).__init__(message=message)
class NotHubDatasetToAppendException(HubException):
def __init__(self):
message = (
"Unable to append to the dataset. "
"The provided directory is not empty and doesn't contain information about any Hub Dataset "
)
super(HubException, self).__init__(message=message)
class DynamicTensorNotFoundException(HubException):
def __init__(self):
message = "Unable to find dynamic tensor"
super(HubException, self).__init__(message=message)
class DynamicTensorShapeException(HubException):
def __init__(self, exc_type):
if exc_type == "none":
message = "Parameter 'max_shape' shouldn't contain any 'None' value"
elif exc_type == "length":
message = "Lengths of 'shape' and 'max_shape' should be equal"
elif exc_type == "not_equal":
message = "All not-None values from 'shape' should be equal to the corresponding values in 'max_shape'"
else:
message = "Wrong 'shape' or 'max_shape' values"
super(HubException, self).__init__(message=message)
class NotIterable(HubException):
def __init__(self):
message = "First argument to transform function should be iterable"
super(HubException, self).__init__(message=message)
class AdvancedSlicingNotSupported(HubException):
def __init__(self):
message = "Advanced slicing is not supported, only support index"
super(HubException, self).__init__(message=message)
class NotZarrFolderException(Exception):
pass
class StorageTensorNotFoundException(Exception):
pass