kaggle 1.7.3b1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- kaggle/LICENSE +201 -0
- kaggle/__init__.py +6 -0
- kaggle/api/__init__.py +0 -0
- kaggle/api/kaggle_api.py +614 -0
- kaggle/api/kaggle_api_extended.py +4657 -0
- kaggle/cli.py +1606 -0
- kaggle/configuration.py +206 -0
- kaggle/models/__init__.py +0 -0
- kaggle/models/api_blob_type.py +4 -0
- kaggle/models/dataset_column.py +228 -0
- kaggle/models/dataset_new_request.py +385 -0
- kaggle/models/dataset_new_version_request.py +287 -0
- kaggle/models/dataset_update_settings_request.py +310 -0
- kaggle/models/kaggle_models_extended.py +276 -0
- kaggle/models/kernel_push_request.py +556 -0
- kaggle/models/model_instance_new_version_request.py +145 -0
- kaggle/models/model_instance_update_request.py +351 -0
- kaggle/models/model_new_instance_request.py +417 -0
- kaggle/models/model_new_request.py +314 -0
- kaggle/models/model_update_request.py +282 -0
- kaggle/models/start_blob_upload_request.py +232 -0
- kaggle/models/start_blob_upload_response.py +137 -0
- kaggle/models/upload_file.py +169 -0
- kaggle/test/__init__.py +0 -0
- kaggle/test/test_authenticate.py +43 -0
- kaggle-1.7.3b1.dist-info/METADATA +348 -0
- kaggle-1.7.3b1.dist-info/RECORD +89 -0
- kaggle-1.7.3b1.dist-info/WHEEL +4 -0
- kaggle-1.7.3b1.dist-info/entry_points.txt +2 -0
- kaggle-1.7.3b1.dist-info/licenses/LICENSE.txt +201 -0
- kagglesdk/LICENSE +201 -0
- kagglesdk/__init__.py +2 -0
- kagglesdk/admin/__init__.py +0 -0
- kagglesdk/admin/services/__init__.py +0 -0
- kagglesdk/admin/services/inbox_file_service.py +22 -0
- kagglesdk/admin/types/__init__.py +0 -0
- kagglesdk/admin/types/inbox_file_service.py +74 -0
- kagglesdk/blobs/__init__.py +0 -0
- kagglesdk/blobs/services/__init__.py +0 -0
- kagglesdk/blobs/services/blob_api_service.py +25 -0
- kagglesdk/blobs/types/__init__.py +0 -0
- kagglesdk/blobs/types/blob_api_service.py +177 -0
- kagglesdk/common/__init__.py +0 -0
- kagglesdk/common/types/__init__.py +0 -0
- kagglesdk/common/types/file_download.py +102 -0
- kagglesdk/common/types/http_redirect.py +105 -0
- kagglesdk/competitions/__init__.py +0 -0
- kagglesdk/competitions/services/__init__.py +0 -0
- kagglesdk/competitions/services/competition_api_service.py +129 -0
- kagglesdk/competitions/types/__init__.py +0 -0
- kagglesdk/competitions/types/competition_api_service.py +1874 -0
- kagglesdk/competitions/types/competition_enums.py +53 -0
- kagglesdk/competitions/types/submission_status.py +9 -0
- kagglesdk/datasets/__init__.py +0 -0
- kagglesdk/datasets/services/__init__.py +0 -0
- kagglesdk/datasets/services/dataset_api_service.py +170 -0
- kagglesdk/datasets/types/__init__.py +0 -0
- kagglesdk/datasets/types/dataset_api_service.py +2777 -0
- kagglesdk/datasets/types/dataset_enums.py +82 -0
- kagglesdk/datasets/types/dataset_types.py +646 -0
- kagglesdk/education/__init__.py +0 -0
- kagglesdk/education/services/__init__.py +0 -0
- kagglesdk/education/services/education_api_service.py +19 -0
- kagglesdk/education/types/__init__.py +0 -0
- kagglesdk/education/types/education_api_service.py +248 -0
- kagglesdk/education/types/education_service.py +139 -0
- kagglesdk/kaggle_client.py +66 -0
- kagglesdk/kaggle_env.py +42 -0
- kagglesdk/kaggle_http_client.py +316 -0
- kagglesdk/kaggle_object.py +293 -0
- kagglesdk/kernels/__init__.py +0 -0
- kagglesdk/kernels/services/__init__.py +0 -0
- kagglesdk/kernels/services/kernels_api_service.py +109 -0
- kagglesdk/kernels/types/__init__.py +0 -0
- kagglesdk/kernels/types/kernels_api_service.py +1951 -0
- kagglesdk/kernels/types/kernels_enums.py +33 -0
- kagglesdk/models/__init__.py +0 -0
- kagglesdk/models/services/__init__.py +0 -0
- kagglesdk/models/services/model_api_service.py +255 -0
- kagglesdk/models/services/model_service.py +19 -0
- kagglesdk/models/types/__init__.py +0 -0
- kagglesdk/models/types/model_api_service.py +3719 -0
- kagglesdk/models/types/model_enums.py +60 -0
- kagglesdk/models/types/model_service.py +275 -0
- kagglesdk/models/types/model_types.py +286 -0
- kagglesdk/test/test_client.py +45 -0
- kagglesdk/users/__init__.py +0 -0
- kagglesdk/users/types/__init__.py +0 -0
- kagglesdk/users/types/users_enums.py +22 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
#!/usr/bin/python
|
|
2
|
+
#
|
|
3
|
+
# Copyright 2024 Kaggle Inc
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
# coding: utf-8
|
|
18
|
+
|
|
19
|
+
import pprint
|
|
20
|
+
import re # noqa: F401
|
|
21
|
+
|
|
22
|
+
import six
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class DatasetUpdateSettingsRequest(object):
|
|
26
|
+
"""
|
|
27
|
+
Attributes:
|
|
28
|
+
project_types (dict): The key is attribute name
|
|
29
|
+
and the value is attribute type.
|
|
30
|
+
attribute_map (dict): The key is attribute name
|
|
31
|
+
and the value is json key in definition.
|
|
32
|
+
"""
|
|
33
|
+
project_types = {
|
|
34
|
+
'title': 'str',
|
|
35
|
+
'subtitle': 'str',
|
|
36
|
+
'description': 'str',
|
|
37
|
+
'is_private': 'bool',
|
|
38
|
+
'licenses': 'list[object]',
|
|
39
|
+
'keywords': 'list[str]',
|
|
40
|
+
'collaborators': 'list[object]',
|
|
41
|
+
'data': 'list[object]'
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
attribute_map = {
|
|
45
|
+
'title': 'title',
|
|
46
|
+
'subtitle': 'subtitle',
|
|
47
|
+
'description': 'description',
|
|
48
|
+
'is_private': 'isPrivate',
|
|
49
|
+
'licenses': 'licenses',
|
|
50
|
+
'keywords': 'keywords',
|
|
51
|
+
'collaborators': 'collaborators',
|
|
52
|
+
'data': 'data'
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
def __init__(self, title=None, subtitle=None, description=None, is_private=None, licenses=None, keywords=None, collaborators=None, data=None): # noqa: E501
|
|
56
|
+
|
|
57
|
+
self._title = None
|
|
58
|
+
self._subtitle = None
|
|
59
|
+
self._description = None
|
|
60
|
+
self._is_private = None
|
|
61
|
+
self._licenses = None
|
|
62
|
+
self._keywords = None
|
|
63
|
+
self._collaborators = None
|
|
64
|
+
self._data = None
|
|
65
|
+
self.discriminator = None
|
|
66
|
+
|
|
67
|
+
if title is not None:
|
|
68
|
+
self.title = title
|
|
69
|
+
if subtitle is not None:
|
|
70
|
+
self.subtitle = subtitle
|
|
71
|
+
if description is not None:
|
|
72
|
+
self.description = description
|
|
73
|
+
if is_private is not None:
|
|
74
|
+
self.is_private = is_private
|
|
75
|
+
if licenses is not None:
|
|
76
|
+
self.licenses = licenses
|
|
77
|
+
if keywords is not None:
|
|
78
|
+
self.keywords = keywords
|
|
79
|
+
if collaborators is not None:
|
|
80
|
+
self.collaborators = collaborators
|
|
81
|
+
if data is not None:
|
|
82
|
+
self.data = data
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def title(self):
|
|
86
|
+
"""Gets the title of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
87
|
+
|
|
88
|
+
Title of the dataset # noqa: E501
|
|
89
|
+
|
|
90
|
+
:return: The title of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
91
|
+
:rtype: str
|
|
92
|
+
"""
|
|
93
|
+
return self._title
|
|
94
|
+
|
|
95
|
+
@title.setter
|
|
96
|
+
def title(self, title):
|
|
97
|
+
"""Sets the title of this DatasetUpdateSettingsRequest.
|
|
98
|
+
|
|
99
|
+
Title of the dataset # noqa: E501
|
|
100
|
+
|
|
101
|
+
:param title: The title of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
102
|
+
:type: str
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
self._title = title
|
|
106
|
+
|
|
107
|
+
@property
|
|
108
|
+
def subtitle(self):
|
|
109
|
+
"""Gets the subtitle of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
110
|
+
|
|
111
|
+
Subtitle of the dataset # noqa: E501
|
|
112
|
+
|
|
113
|
+
:return: The subtitle of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
114
|
+
:rtype: str
|
|
115
|
+
"""
|
|
116
|
+
return self._subtitle
|
|
117
|
+
|
|
118
|
+
@subtitle.setter
|
|
119
|
+
def subtitle(self, subtitle):
|
|
120
|
+
"""Sets the subtitle of this DatasetUpdateSettingsRequest.
|
|
121
|
+
|
|
122
|
+
Subtitle of the dataset # noqa: E501
|
|
123
|
+
|
|
124
|
+
:param subtitle: The subtitle of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
125
|
+
:type: str
|
|
126
|
+
"""
|
|
127
|
+
|
|
128
|
+
self._subtitle = subtitle
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
def description(self):
|
|
132
|
+
"""Gets the description of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
133
|
+
|
|
134
|
+
Decription of the dataset # noqa: E501
|
|
135
|
+
|
|
136
|
+
:return: The description of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
137
|
+
:rtype: str
|
|
138
|
+
"""
|
|
139
|
+
return self._description
|
|
140
|
+
|
|
141
|
+
@description.setter
|
|
142
|
+
def description(self, description):
|
|
143
|
+
"""Sets the description of this DatasetUpdateSettingsRequest.
|
|
144
|
+
|
|
145
|
+
Decription of the dataset # noqa: E501
|
|
146
|
+
|
|
147
|
+
:param description: The description of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
148
|
+
:type: str
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
self._description = description
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def is_private(self):
|
|
155
|
+
"""Gets the is_private of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
156
|
+
|
|
157
|
+
Whether or not the dataset should be private # noqa: E501
|
|
158
|
+
|
|
159
|
+
:return: The is_private of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
160
|
+
:rtype: bool
|
|
161
|
+
"""
|
|
162
|
+
return self._is_private
|
|
163
|
+
|
|
164
|
+
@is_private.setter
|
|
165
|
+
def is_private(self, is_private):
|
|
166
|
+
"""Sets the is_private of this DatasetUpdateSettingsRequest.
|
|
167
|
+
|
|
168
|
+
Whether or not the dataset should be private # noqa: E501
|
|
169
|
+
|
|
170
|
+
:param is_private: The is_private of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
171
|
+
:type: bool
|
|
172
|
+
"""
|
|
173
|
+
|
|
174
|
+
self._is_private = is_private
|
|
175
|
+
|
|
176
|
+
@property
|
|
177
|
+
def licenses(self):
|
|
178
|
+
"""Gets the licenses of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
179
|
+
|
|
180
|
+
A list of licenses that apply to this dataset # noqa: E501
|
|
181
|
+
|
|
182
|
+
:return: The licenses of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
183
|
+
:rtype: list[object]
|
|
184
|
+
"""
|
|
185
|
+
return self._licenses
|
|
186
|
+
|
|
187
|
+
@licenses.setter
|
|
188
|
+
def licenses(self, licenses):
|
|
189
|
+
"""Sets the licenses of this DatasetUpdateSettingsRequest.
|
|
190
|
+
|
|
191
|
+
A list of licenses that apply to this dataset # noqa: E501
|
|
192
|
+
|
|
193
|
+
:param licenses: The licenses of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
194
|
+
:type: list[object]
|
|
195
|
+
"""
|
|
196
|
+
|
|
197
|
+
self._licenses = licenses
|
|
198
|
+
|
|
199
|
+
@property
|
|
200
|
+
def keywords(self):
|
|
201
|
+
"""Gets the keywords of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
202
|
+
|
|
203
|
+
A list of keywords that apply to this dataset # noqa: E501
|
|
204
|
+
|
|
205
|
+
:return: The keywords of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
206
|
+
:rtype: list[str]
|
|
207
|
+
"""
|
|
208
|
+
return self._keywords
|
|
209
|
+
|
|
210
|
+
@keywords.setter
|
|
211
|
+
def keywords(self, keywords):
|
|
212
|
+
"""Sets the keywords of this DatasetUpdateSettingsRequest.
|
|
213
|
+
|
|
214
|
+
A list of keywords that apply to this dataset # noqa: E501
|
|
215
|
+
|
|
216
|
+
:param keywords: The keywords of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
217
|
+
:type: list[str]
|
|
218
|
+
"""
|
|
219
|
+
|
|
220
|
+
self._keywords = keywords
|
|
221
|
+
|
|
222
|
+
@property
|
|
223
|
+
def collaborators(self):
|
|
224
|
+
"""Gets the collaborators of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
225
|
+
|
|
226
|
+
A list of collaborators that may read or edit this dataset # noqa: E501
|
|
227
|
+
|
|
228
|
+
:return: The collaborators of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
229
|
+
:rtype: list[object]
|
|
230
|
+
"""
|
|
231
|
+
return self._collaborators
|
|
232
|
+
|
|
233
|
+
@collaborators.setter
|
|
234
|
+
def collaborators(self, collaborators):
|
|
235
|
+
"""Sets the collaborators of this DatasetUpdateSettingsRequest.
|
|
236
|
+
|
|
237
|
+
A list of collaborators that may read or edit this dataset # noqa: E501
|
|
238
|
+
|
|
239
|
+
:param collaborators: The collaborators of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
240
|
+
:type: list[object]
|
|
241
|
+
"""
|
|
242
|
+
|
|
243
|
+
self._collaborators = collaborators
|
|
244
|
+
|
|
245
|
+
@property
|
|
246
|
+
def data(self):
|
|
247
|
+
"""Gets the data of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
248
|
+
|
|
249
|
+
A list containing metadata for each file in the dataset # noqa: E501
|
|
250
|
+
|
|
251
|
+
:return: The data of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
252
|
+
:rtype: list[object]
|
|
253
|
+
"""
|
|
254
|
+
return self._data
|
|
255
|
+
|
|
256
|
+
@data.setter
|
|
257
|
+
def data(self, data):
|
|
258
|
+
"""Sets the data of this DatasetUpdateSettingsRequest.
|
|
259
|
+
|
|
260
|
+
A list containing metadata for each file in the dataset # noqa: E501
|
|
261
|
+
|
|
262
|
+
:param data: The data of this DatasetUpdateSettingsRequest. # noqa: E501
|
|
263
|
+
:type: list[object]
|
|
264
|
+
"""
|
|
265
|
+
|
|
266
|
+
self._data = data
|
|
267
|
+
|
|
268
|
+
def to_dict(self):
|
|
269
|
+
"""Returns the model properties as a dict"""
|
|
270
|
+
result = {}
|
|
271
|
+
|
|
272
|
+
for attr, _ in six.iteritems(self.project_types):
|
|
273
|
+
value = getattr(self, attr)
|
|
274
|
+
if isinstance(value, list):
|
|
275
|
+
result[attr] = list(map(
|
|
276
|
+
lambda x: x.to_dict() if hasattr(x, "to_dict") else x,
|
|
277
|
+
value
|
|
278
|
+
))
|
|
279
|
+
elif hasattr(value, "to_dict"):
|
|
280
|
+
result[attr] = value.to_dict()
|
|
281
|
+
elif isinstance(value, dict):
|
|
282
|
+
result[attr] = dict(map(
|
|
283
|
+
lambda item: (item[0], item[1].to_dict())
|
|
284
|
+
if hasattr(item[1], "to_dict") else item,
|
|
285
|
+
value.items()
|
|
286
|
+
))
|
|
287
|
+
else:
|
|
288
|
+
result[attr] = value
|
|
289
|
+
|
|
290
|
+
return result
|
|
291
|
+
|
|
292
|
+
def to_str(self):
|
|
293
|
+
"""Returns the string representation of the model"""
|
|
294
|
+
return pprint.pformat(self.to_dict())
|
|
295
|
+
|
|
296
|
+
def __repr__(self):
|
|
297
|
+
"""For `print` and `pprint`"""
|
|
298
|
+
return self.to_str()
|
|
299
|
+
|
|
300
|
+
def __eq__(self, other):
|
|
301
|
+
"""Returns true if both objects are equal"""
|
|
302
|
+
if not isinstance(other, DatasetUpdateSettingsRequest):
|
|
303
|
+
return False
|
|
304
|
+
|
|
305
|
+
return self.__dict__ == other.__dict__
|
|
306
|
+
|
|
307
|
+
def __ne__(self, other):
|
|
308
|
+
"""Returns true if both objects are not equal"""
|
|
309
|
+
return not self == other
|
|
310
|
+
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
#!/usr/bin/python
|
|
2
|
+
#
|
|
3
|
+
# Copyright 2019 Kaggle Inc
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
|
|
17
|
+
# coding=utf-8
|
|
18
|
+
from datetime import datetime
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class Competition(object):
|
|
22
|
+
|
|
23
|
+
def __init__(self, init_dict):
|
|
24
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
25
|
+
self.__dict__.update(parsed_dict)
|
|
26
|
+
self.tags = [Tag(t) for t in self.tags]
|
|
27
|
+
|
|
28
|
+
def __repr__(self):
|
|
29
|
+
return self.ref
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SubmitResult(object):
|
|
33
|
+
|
|
34
|
+
def __init__(self, init_dict):
|
|
35
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
36
|
+
self.__dict__.update(parsed_dict)
|
|
37
|
+
|
|
38
|
+
def __repr__(self):
|
|
39
|
+
return self.message
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Submission(object):
|
|
43
|
+
|
|
44
|
+
def __init__(self, init_dict):
|
|
45
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
46
|
+
self.__dict__.update(parsed_dict)
|
|
47
|
+
if self.totalBytes is None:
|
|
48
|
+
self.size = None
|
|
49
|
+
else:
|
|
50
|
+
self.size = File.get_size(self.totalBytes)
|
|
51
|
+
|
|
52
|
+
def __repr__(self):
|
|
53
|
+
return str(self.ref)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class LeaderboardEntry(object):
|
|
57
|
+
|
|
58
|
+
def __init__(self, init_dict):
|
|
59
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
60
|
+
self.__dict__.update(parsed_dict)
|
|
61
|
+
|
|
62
|
+
def __repr__(self):
|
|
63
|
+
return self.teamId
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class Dataset(object):
|
|
67
|
+
|
|
68
|
+
def __init__(self, init_dict):
|
|
69
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
70
|
+
self.__dict__.update(parsed_dict)
|
|
71
|
+
self.tags = [Tag(t) for t in self.tags]
|
|
72
|
+
self.files = [File(f) for f in self.files]
|
|
73
|
+
self.versions = [DatasetVersion(v) for v in self.versions]
|
|
74
|
+
self.size = File.get_size(self.totalBytes)
|
|
75
|
+
|
|
76
|
+
def __repr__(self):
|
|
77
|
+
return self.ref
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class Model(object):
|
|
81
|
+
|
|
82
|
+
def __init__(self, init_dict):
|
|
83
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
84
|
+
self.__dict__.update(parsed_dict)
|
|
85
|
+
|
|
86
|
+
def __repr__(self):
|
|
87
|
+
return self.ref
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class Metadata(object):
|
|
91
|
+
|
|
92
|
+
def __init__(self, init_info):
|
|
93
|
+
parsed_info = {k: parse(v) for k, v in init_info.items()}
|
|
94
|
+
# backwards compatibility
|
|
95
|
+
self.id = parsed_info["ownerUser"] + "/" + parsed_info['datasetSlug']
|
|
96
|
+
self.id_no = parsed_info['datasetId']
|
|
97
|
+
self.__dict__.update(parsed_info)
|
|
98
|
+
|
|
99
|
+
def __repr__(self):
|
|
100
|
+
return str(self.datasetId)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class DatasetVersion(object):
|
|
104
|
+
|
|
105
|
+
def __init__(self, init_dict):
|
|
106
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
107
|
+
self.__dict__.update(parsed_dict)
|
|
108
|
+
|
|
109
|
+
def __repr__(self):
|
|
110
|
+
return str(self.versionNumber)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class File(object):
|
|
114
|
+
|
|
115
|
+
def __init__(self, init_dict):
|
|
116
|
+
try: # TODO Remove try-block
|
|
117
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
118
|
+
self.__dict__.update(parsed_dict)
|
|
119
|
+
self.size = File.get_size(self.totalBytes)
|
|
120
|
+
except AttributeError:
|
|
121
|
+
self.name = init_dict.name
|
|
122
|
+
self.creation_date = init_dict.creation_date
|
|
123
|
+
self.size = File.get_size(init_dict.total_bytes)
|
|
124
|
+
|
|
125
|
+
def __repr__(self):
|
|
126
|
+
return self.name
|
|
127
|
+
|
|
128
|
+
@staticmethod
|
|
129
|
+
def get_size(size, precision=0):
|
|
130
|
+
suffixes = ['B', 'KB', 'MB', 'GB', 'TB']
|
|
131
|
+
suffix_index = 0
|
|
132
|
+
while size >= 1024 and suffix_index < 4:
|
|
133
|
+
suffix_index += 1
|
|
134
|
+
size /= 1024.0
|
|
135
|
+
return '%.*f%s' % (precision, size, suffixes[suffix_index])
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class Tag(object):
|
|
139
|
+
|
|
140
|
+
def __init__(self, init_dict):
|
|
141
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
142
|
+
self.__dict__.update(parsed_dict)
|
|
143
|
+
|
|
144
|
+
def __repr__(self):
|
|
145
|
+
return self.ref
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
class DatasetNewVersionResponse(object):
|
|
149
|
+
|
|
150
|
+
def __init__(self, init_dict):
|
|
151
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
152
|
+
self.__dict__.update(parsed_dict)
|
|
153
|
+
|
|
154
|
+
def __repr__(self):
|
|
155
|
+
return self.url
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class DatasetNewResponse(object):
|
|
159
|
+
|
|
160
|
+
def __init__(self, init_dict):
|
|
161
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
162
|
+
self.__dict__.update(parsed_dict)
|
|
163
|
+
|
|
164
|
+
def __repr__(self):
|
|
165
|
+
return self.url
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
class ListFilesResult(object):
|
|
169
|
+
|
|
170
|
+
def __init__(self, init_dict):
|
|
171
|
+
try: # TODO Remove try-block
|
|
172
|
+
self.error_message = init_dict['errorMessage']
|
|
173
|
+
files = init_dict['datasetFiles']
|
|
174
|
+
token = init_dict['nextPageToken']
|
|
175
|
+
except TypeError:
|
|
176
|
+
self.error_message = init_dict.error_message
|
|
177
|
+
files = init_dict.dataset_files
|
|
178
|
+
token = init_dict.next_page_token
|
|
179
|
+
if files:
|
|
180
|
+
self.files = [File(f) for f in files]
|
|
181
|
+
else:
|
|
182
|
+
self.files = {}
|
|
183
|
+
if token:
|
|
184
|
+
self.nextPageToken = token
|
|
185
|
+
else:
|
|
186
|
+
self.nextPageToken = ""
|
|
187
|
+
|
|
188
|
+
def __repr__(self):
|
|
189
|
+
return self.error_message
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
class Kernel:
|
|
193
|
+
|
|
194
|
+
def __init__(self, init_dict):
|
|
195
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
196
|
+
self.__dict__.update(parsed_dict)
|
|
197
|
+
|
|
198
|
+
def __repr__(self):
|
|
199
|
+
return self.title
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class KernelPushResponse(object):
|
|
203
|
+
|
|
204
|
+
def __init__(self, init_dict):
|
|
205
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
206
|
+
self.__dict__.update(parsed_dict)
|
|
207
|
+
|
|
208
|
+
def __repr__(self):
|
|
209
|
+
return self.newUrl
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
class ModelNewResponse(object):
|
|
213
|
+
|
|
214
|
+
def __init__(self, init_dict):
|
|
215
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
216
|
+
self.__dict__.update(parsed_dict)
|
|
217
|
+
|
|
218
|
+
def __repr__(self):
|
|
219
|
+
return self.url
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
class ModelDeleteResponse(object):
|
|
223
|
+
|
|
224
|
+
def __init__(self, init_dict):
|
|
225
|
+
parsed_dict = {k: parse(v) for k, v in init_dict.items()}
|
|
226
|
+
self.__dict__.update(parsed_dict)
|
|
227
|
+
|
|
228
|
+
def __repr__(self):
|
|
229
|
+
return self.error
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def parse(string):
|
|
233
|
+
time_formats = [
|
|
234
|
+
'%Y-%m-%dT%H:%M:%S', '%Y-%m-%dT%H:%M:%SZ', '%Y-%m-%dT%H:%M:%S.%f',
|
|
235
|
+
'%Y-%m-%dT%H:%M:%S.%fZ'
|
|
236
|
+
]
|
|
237
|
+
for t in time_formats:
|
|
238
|
+
try:
|
|
239
|
+
result = datetime.strptime(string[:26], t).replace(microsecond=0)
|
|
240
|
+
return result
|
|
241
|
+
except:
|
|
242
|
+
pass
|
|
243
|
+
return string
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class ResumableUploadResult(object):
|
|
247
|
+
# Upload was complete, i.e., all bytes were received by the server.
|
|
248
|
+
COMPLETE = 1
|
|
249
|
+
|
|
250
|
+
# There was a non-transient error during the upload or the upload expired.
|
|
251
|
+
# The upload cannot be resumed so it should be restarted from scratch
|
|
252
|
+
# (i.e., call /api/v1/files/upload to initiate the upload and get the
|
|
253
|
+
# create/upload url and token).
|
|
254
|
+
FAILED = 2
|
|
255
|
+
|
|
256
|
+
# Upload was interrupted due to some (transient) failure but it can be
|
|
257
|
+
# safely resumed.
|
|
258
|
+
INCOMPLETE = 3
|
|
259
|
+
|
|
260
|
+
def __init__(self, result, bytes_uploaded=None):
|
|
261
|
+
self.result = result
|
|
262
|
+
self.bytes_uploaded = bytes_uploaded
|
|
263
|
+
self.start_at = 0 if bytes_uploaded is None else bytes_uploaded + 1
|
|
264
|
+
|
|
265
|
+
@staticmethod
|
|
266
|
+
def Complete():
|
|
267
|
+
return ResumableUploadResult(ResumableUploadResult.COMPLETE)
|
|
268
|
+
|
|
269
|
+
@staticmethod
|
|
270
|
+
def Failed():
|
|
271
|
+
return ResumableUploadResult(ResumableUploadResult.FAILED)
|
|
272
|
+
|
|
273
|
+
@staticmethod
|
|
274
|
+
def Incomplete(bytes_uploaded=None):
|
|
275
|
+
return ResumableUploadResult(ResumableUploadResult.INCOMPLETE,
|
|
276
|
+
bytes_uploaded)
|