datacrunch 1.16.0__py3-none-any.whl → 1.17.1__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.
- datacrunch/__init__.py +52 -2
- datacrunch/datacrunch.py +44 -81
- datacrunch-1.17.1.dist-info/METADATA +30 -0
- datacrunch-1.17.1.dist-info/RECORD +5 -0
- {datacrunch-1.16.0.dist-info → datacrunch-1.17.1.dist-info}/WHEEL +1 -1
- datacrunch/InferenceClient/__init__.py +0 -3
- datacrunch/InferenceClient/inference_client.py +0 -514
- datacrunch/_version.py +0 -6
- datacrunch/authentication/__init__.py +0 -0
- datacrunch/authentication/authentication.py +0 -105
- datacrunch/balance/__init__.py +0 -0
- datacrunch/balance/balance.py +0 -50
- datacrunch/constants.py +0 -109
- datacrunch/containers/__init__.py +0 -33
- datacrunch/containers/containers.py +0 -1109
- datacrunch/exceptions.py +0 -29
- datacrunch/helpers.py +0 -18
- datacrunch/http_client/__init__.py +0 -0
- datacrunch/http_client/http_client.py +0 -241
- datacrunch/images/__init__.py +0 -0
- datacrunch/images/images.py +0 -93
- datacrunch/instance_types/__init__.py +0 -0
- datacrunch/instance_types/instance_types.py +0 -195
- datacrunch/instances/__init__.py +0 -0
- datacrunch/instances/instances.py +0 -259
- datacrunch/locations/__init__.py +0 -0
- datacrunch/locations/locations.py +0 -15
- datacrunch/ssh_keys/__init__.py +0 -0
- datacrunch/ssh_keys/ssh_keys.py +0 -111
- datacrunch/startup_scripts/__init__.py +0 -0
- datacrunch/startup_scripts/startup_scripts.py +0 -115
- datacrunch/volume_types/__init__.py +0 -0
- datacrunch/volume_types/volume_types.py +0 -68
- datacrunch/volumes/__init__.py +0 -0
- datacrunch/volumes/volumes.py +0 -385
- datacrunch-1.16.0.dist-info/METADATA +0 -182
- datacrunch-1.16.0.dist-info/RECORD +0 -35
datacrunch/volumes/volumes.py
DELETED
|
@@ -1,385 +0,0 @@
|
|
|
1
|
-
from typing import List, Union, Optional
|
|
2
|
-
from datacrunch.constants import VolumeActions, Locations
|
|
3
|
-
from datacrunch.helpers import stringify_class_object_properties
|
|
4
|
-
|
|
5
|
-
VOLUMES_ENDPOINT = '/volumes'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class Volume:
|
|
9
|
-
"""A volume model class"""
|
|
10
|
-
|
|
11
|
-
def __init__(
|
|
12
|
-
self,
|
|
13
|
-
id: str,
|
|
14
|
-
status: str,
|
|
15
|
-
name: str,
|
|
16
|
-
size: int,
|
|
17
|
-
type: str,
|
|
18
|
-
is_os_volume: bool,
|
|
19
|
-
created_at: str,
|
|
20
|
-
target: str = None,
|
|
21
|
-
location: str = Locations.FIN_03,
|
|
22
|
-
instance_id: str = None,
|
|
23
|
-
ssh_key_ids: List[str] = [],
|
|
24
|
-
deleted_at: str = None,
|
|
25
|
-
) -> None:
|
|
26
|
-
"""Initialize the volume object
|
|
27
|
-
|
|
28
|
-
:param id: volume id
|
|
29
|
-
:type id: str
|
|
30
|
-
:param status: volume status
|
|
31
|
-
:type status: str
|
|
32
|
-
:param name: volume name
|
|
33
|
-
:type name: str
|
|
34
|
-
:param size: volume size in GB
|
|
35
|
-
:type size: int
|
|
36
|
-
:param type: volume type
|
|
37
|
-
:type type: str
|
|
38
|
-
:param is_os_volume: indication whether this is an operating systen volume
|
|
39
|
-
:type is_os_volume: bool
|
|
40
|
-
:param created_at: the time the volume was created (UTC)
|
|
41
|
-
:type created_at: str
|
|
42
|
-
:param target: target device e.g. vda
|
|
43
|
-
:type target: str, optional
|
|
44
|
-
:param location: datacenter location, defaults to "FIN-03"
|
|
45
|
-
:type location: str, optional
|
|
46
|
-
:param instance_id: the instance id the volume is attached to, None if detached
|
|
47
|
-
:type instance_id: str
|
|
48
|
-
:param ssh_key_ids: list of ssh keys ids
|
|
49
|
-
:type ssh_key_ids: List[str]
|
|
50
|
-
:param deleted_at: the time the volume was deleted (UTC), defaults to None
|
|
51
|
-
:type deleted_at: str, optional
|
|
52
|
-
"""
|
|
53
|
-
self._id = id
|
|
54
|
-
self._status = status
|
|
55
|
-
self._name = name
|
|
56
|
-
self._size = size
|
|
57
|
-
self._type = type
|
|
58
|
-
self._is_os_volume = is_os_volume
|
|
59
|
-
self._created_at = created_at
|
|
60
|
-
self._target = target
|
|
61
|
-
self._location = location
|
|
62
|
-
self._instance_id = instance_id
|
|
63
|
-
self._ssh_key_ids = ssh_key_ids
|
|
64
|
-
self._deleted_at = deleted_at
|
|
65
|
-
|
|
66
|
-
@property
|
|
67
|
-
def id(self) -> str:
|
|
68
|
-
"""Get the volume id
|
|
69
|
-
|
|
70
|
-
:return: volume id
|
|
71
|
-
:rtype: str
|
|
72
|
-
"""
|
|
73
|
-
return self._id
|
|
74
|
-
|
|
75
|
-
@property
|
|
76
|
-
def status(self) -> str:
|
|
77
|
-
"""Get the volume status
|
|
78
|
-
|
|
79
|
-
:return: volume status
|
|
80
|
-
:rtype: str
|
|
81
|
-
"""
|
|
82
|
-
return self._status
|
|
83
|
-
|
|
84
|
-
@property
|
|
85
|
-
def name(self) -> str:
|
|
86
|
-
"""Get the volume name
|
|
87
|
-
|
|
88
|
-
:return: volume name
|
|
89
|
-
:rtype: str
|
|
90
|
-
"""
|
|
91
|
-
return self._name
|
|
92
|
-
|
|
93
|
-
@property
|
|
94
|
-
def size(self) -> int:
|
|
95
|
-
"""Get the volume size
|
|
96
|
-
|
|
97
|
-
:return: volume size
|
|
98
|
-
:rtype: int
|
|
99
|
-
"""
|
|
100
|
-
return self._size
|
|
101
|
-
|
|
102
|
-
@property
|
|
103
|
-
def type(self) -> int:
|
|
104
|
-
"""Get the volume type
|
|
105
|
-
|
|
106
|
-
:return: volume type
|
|
107
|
-
:rtype: string
|
|
108
|
-
"""
|
|
109
|
-
return self._type
|
|
110
|
-
|
|
111
|
-
@property
|
|
112
|
-
def is_os_volume(self) -> bool:
|
|
113
|
-
"""Return true iff the volume contains an operating system
|
|
114
|
-
|
|
115
|
-
:return: true iff the volume contains an OS
|
|
116
|
-
:rtype: bool
|
|
117
|
-
"""
|
|
118
|
-
return self._is_os_volume
|
|
119
|
-
|
|
120
|
-
@property
|
|
121
|
-
def created_at(self) -> str:
|
|
122
|
-
"""Get the time when the volume was created (UTC)
|
|
123
|
-
|
|
124
|
-
:return: time
|
|
125
|
-
:rtype: str
|
|
126
|
-
"""
|
|
127
|
-
return self._created_at
|
|
128
|
-
|
|
129
|
-
@property
|
|
130
|
-
def target(self) -> Optional[str]:
|
|
131
|
-
"""Get the target device
|
|
132
|
-
|
|
133
|
-
:return: target device
|
|
134
|
-
:rtype: str, optional
|
|
135
|
-
"""
|
|
136
|
-
return self._target
|
|
137
|
-
|
|
138
|
-
@property
|
|
139
|
-
def location(self) -> str:
|
|
140
|
-
"""Get the volume datacenter location
|
|
141
|
-
|
|
142
|
-
:return: datacenter location
|
|
143
|
-
:rtype: str
|
|
144
|
-
"""
|
|
145
|
-
return self._location
|
|
146
|
-
|
|
147
|
-
@property
|
|
148
|
-
def instance_id(self) -> Optional[str]:
|
|
149
|
-
"""Get the instance id the volume is attached to, if attached. Otherwise None
|
|
150
|
-
|
|
151
|
-
:return: instance id if attached, None otherwise
|
|
152
|
-
:rtype: str, optional
|
|
153
|
-
"""
|
|
154
|
-
return self._instance_id
|
|
155
|
-
|
|
156
|
-
@property
|
|
157
|
-
def ssh_key_ids(self) -> List[str]:
|
|
158
|
-
"""Get the SSH key IDs of the instance
|
|
159
|
-
|
|
160
|
-
:return: SSH key IDs
|
|
161
|
-
:rtype: List[str]
|
|
162
|
-
"""
|
|
163
|
-
return self._ssh_key_ids
|
|
164
|
-
|
|
165
|
-
@property
|
|
166
|
-
def deleted_at(self) -> Optional[str]:
|
|
167
|
-
"""Get the time when the volume was deleted (UTC)
|
|
168
|
-
|
|
169
|
-
:return: time
|
|
170
|
-
:rtype: str
|
|
171
|
-
"""
|
|
172
|
-
return self._deleted_at
|
|
173
|
-
|
|
174
|
-
@classmethod
|
|
175
|
-
def create_from_dict(cls: 'Volume', volume_dict: dict) -> 'Volume':
|
|
176
|
-
"""Create a Volume object from a dictionary
|
|
177
|
-
|
|
178
|
-
:param volume_dict: dictionary representing the volume
|
|
179
|
-
:type volume_dict: dict
|
|
180
|
-
:return: Volume
|
|
181
|
-
:rtype: Volume
|
|
182
|
-
"""
|
|
183
|
-
|
|
184
|
-
return cls(
|
|
185
|
-
id=volume_dict['id'],
|
|
186
|
-
status=volume_dict['status'],
|
|
187
|
-
name=volume_dict['name'],
|
|
188
|
-
size=volume_dict['size'],
|
|
189
|
-
type=volume_dict['type'],
|
|
190
|
-
is_os_volume=volume_dict['is_os_volume'],
|
|
191
|
-
created_at=volume_dict['created_at'],
|
|
192
|
-
target=volume_dict['target'],
|
|
193
|
-
location=volume_dict['location'],
|
|
194
|
-
instance_id=volume_dict['instance_id'],
|
|
195
|
-
ssh_key_ids=volume_dict['ssh_key_ids'],
|
|
196
|
-
deleted_at=volume_dict.get('deleted_at'),
|
|
197
|
-
)
|
|
198
|
-
|
|
199
|
-
def __str__(self) -> str:
|
|
200
|
-
"""Returns a string of the json representation of the volume
|
|
201
|
-
|
|
202
|
-
:return: json representation of the volume
|
|
203
|
-
:rtype: str
|
|
204
|
-
"""
|
|
205
|
-
return stringify_class_object_properties(self)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
class VolumesService:
|
|
209
|
-
"""A service for interacting with the volumes endpoint"""
|
|
210
|
-
|
|
211
|
-
def __init__(self, http_client) -> None:
|
|
212
|
-
self._http_client = http_client
|
|
213
|
-
|
|
214
|
-
def get(self, status: str = None) -> List[Volume]:
|
|
215
|
-
"""Get all of the client's non-deleted volumes, or volumes with specific status.
|
|
216
|
-
|
|
217
|
-
:param status: optional, status of the volumes, defaults to None
|
|
218
|
-
:type status: str, optional
|
|
219
|
-
:return: list of volume details objects
|
|
220
|
-
:rtype: List[Volume]
|
|
221
|
-
"""
|
|
222
|
-
volumes_dict = self._http_client.get(VOLUMES_ENDPOINT, params={'status': status}).json()
|
|
223
|
-
return list(map(Volume.create_from_dict, volumes_dict))
|
|
224
|
-
|
|
225
|
-
def get_by_id(self, id: str) -> Volume:
|
|
226
|
-
"""Get a specific volume by its
|
|
227
|
-
|
|
228
|
-
:param id: volume id
|
|
229
|
-
:type id: str
|
|
230
|
-
:return: Volume details object
|
|
231
|
-
:rtype: Volume
|
|
232
|
-
"""
|
|
233
|
-
volume_dict = self._http_client.get(VOLUMES_ENDPOINT + f'/{id}').json()
|
|
234
|
-
|
|
235
|
-
return Volume.create_from_dict(volume_dict)
|
|
236
|
-
|
|
237
|
-
def get_in_trash(self) -> List[Volume]:
|
|
238
|
-
"""Get all volumes that are in trash
|
|
239
|
-
|
|
240
|
-
:return: list of volume details objects
|
|
241
|
-
:rtype: List[Volume]
|
|
242
|
-
"""
|
|
243
|
-
volumes_dicts = self._http_client.get(VOLUMES_ENDPOINT + '/trash').json()
|
|
244
|
-
|
|
245
|
-
return list(map(Volume.create_from_dict, volumes_dicts))
|
|
246
|
-
|
|
247
|
-
def create(
|
|
248
|
-
self,
|
|
249
|
-
type: str,
|
|
250
|
-
name: str,
|
|
251
|
-
size: int,
|
|
252
|
-
instance_id: str = None,
|
|
253
|
-
location: str = Locations.FIN_03,
|
|
254
|
-
) -> Volume:
|
|
255
|
-
"""Create new volume
|
|
256
|
-
|
|
257
|
-
:param type: volume type
|
|
258
|
-
:type type: str
|
|
259
|
-
:param name: volume name
|
|
260
|
-
:type name: str
|
|
261
|
-
:param size: volume size, in GB
|
|
262
|
-
:type size: int
|
|
263
|
-
:param instance_id: Instance id to be attached to, defaults to None
|
|
264
|
-
:type instance_id: str, optional
|
|
265
|
-
:param location: datacenter location, defaults to "FIN-03"
|
|
266
|
-
:type location: str, optional
|
|
267
|
-
:return: the new volume object
|
|
268
|
-
:rtype: Volume
|
|
269
|
-
"""
|
|
270
|
-
payload = {
|
|
271
|
-
'type': type,
|
|
272
|
-
'name': name,
|
|
273
|
-
'size': size,
|
|
274
|
-
'instance_id': instance_id,
|
|
275
|
-
'location_code': location,
|
|
276
|
-
}
|
|
277
|
-
id = self._http_client.post(VOLUMES_ENDPOINT, json=payload).text
|
|
278
|
-
volume = self.get_by_id(id)
|
|
279
|
-
return volume
|
|
280
|
-
|
|
281
|
-
def attach(self, id_list: Union[List[str], str], instance_id: str) -> None:
|
|
282
|
-
"""Attach multiple volumes or single volume to an instance
|
|
283
|
-
Note: the instance needs to be shut-down (offline)
|
|
284
|
-
|
|
285
|
-
:param id_list: list of volume ids, or a volume id
|
|
286
|
-
:type id_list: Union[List[str], str]
|
|
287
|
-
:param instance_id: instance id the volume(s) will be attached to
|
|
288
|
-
:type instance_id: str
|
|
289
|
-
"""
|
|
290
|
-
payload = {
|
|
291
|
-
'id': id_list,
|
|
292
|
-
'action': VolumeActions.ATTACH,
|
|
293
|
-
'instance_id': instance_id,
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
self._http_client.put(VOLUMES_ENDPOINT, json=payload)
|
|
297
|
-
return
|
|
298
|
-
|
|
299
|
-
def detach(self, id_list: Union[List[str], str]) -> None:
|
|
300
|
-
"""Detach multiple volumes or single volume from an instance(s)
|
|
301
|
-
Note: the instances need to be shut-down (offline)
|
|
302
|
-
|
|
303
|
-
:param id_list: list of volume ids, or a volume id
|
|
304
|
-
:type id_list: Union[List[str], str]
|
|
305
|
-
"""
|
|
306
|
-
payload = {
|
|
307
|
-
'id': id_list,
|
|
308
|
-
'action': VolumeActions.DETACH,
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
self._http_client.put(VOLUMES_ENDPOINT, json=payload)
|
|
312
|
-
return
|
|
313
|
-
|
|
314
|
-
def clone(self, id: str, name: str = None, type: str = None) -> Volume:
|
|
315
|
-
"""Clone a volume or multiple volumes
|
|
316
|
-
|
|
317
|
-
:param id: volume id or list of volume ids
|
|
318
|
-
:type id: str or List[str]
|
|
319
|
-
:param name: new volume name
|
|
320
|
-
:type name: str
|
|
321
|
-
:param type: volume type
|
|
322
|
-
:type type: str, optional
|
|
323
|
-
:return: the new volume object, or a list of volume objects if cloned mutliple volumes
|
|
324
|
-
:rtype: Volume or List[Volume]
|
|
325
|
-
"""
|
|
326
|
-
payload = {'id': id, 'action': VolumeActions.CLONE, 'name': name, 'type': type}
|
|
327
|
-
|
|
328
|
-
# clone volume(s)
|
|
329
|
-
volume_ids_array = self._http_client.put(VOLUMES_ENDPOINT, json=payload).json()
|
|
330
|
-
|
|
331
|
-
# map the IDs into Volume objects
|
|
332
|
-
volumes_array = list(map(lambda volume_id: self.get_by_id(volume_id), volume_ids_array))
|
|
333
|
-
|
|
334
|
-
# if the array has only one element, return that element
|
|
335
|
-
if len(volumes_array) == 1:
|
|
336
|
-
return volumes_array[0]
|
|
337
|
-
|
|
338
|
-
# otherwise return the volumes array
|
|
339
|
-
return volumes_array
|
|
340
|
-
|
|
341
|
-
def rename(self, id_list: Union[List[str], str], name: str) -> None:
|
|
342
|
-
"""Rename multiple volumes or single volume
|
|
343
|
-
|
|
344
|
-
:param id_list: list of volume ids, or a volume id
|
|
345
|
-
:type id_list: Union[List[str], str]
|
|
346
|
-
:param name: new name
|
|
347
|
-
:type name: str
|
|
348
|
-
"""
|
|
349
|
-
payload = {'id': id_list, 'action': VolumeActions.RENAME, 'name': name}
|
|
350
|
-
|
|
351
|
-
self._http_client.put(VOLUMES_ENDPOINT, json=payload)
|
|
352
|
-
return
|
|
353
|
-
|
|
354
|
-
def increase_size(self, id_list: Union[List[str], str], size: int) -> None:
|
|
355
|
-
"""Increase size of multiple volumes or single volume
|
|
356
|
-
|
|
357
|
-
:param id_list: list of volume ids, or a volume id
|
|
358
|
-
:type id_list: Union[List[str], str]
|
|
359
|
-
:param size: new size in GB
|
|
360
|
-
:type size: int
|
|
361
|
-
"""
|
|
362
|
-
payload = {
|
|
363
|
-
'id': id_list,
|
|
364
|
-
'action': VolumeActions.INCREASE_SIZE,
|
|
365
|
-
'size': size,
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
self._http_client.put(VOLUMES_ENDPOINT, json=payload)
|
|
369
|
-
return
|
|
370
|
-
|
|
371
|
-
def delete(self, id_list: Union[List[str], str], is_permanent: bool = False) -> None:
|
|
372
|
-
"""Delete multiple volumes or single volume
|
|
373
|
-
Note: if attached to any instances, they need to be shut-down (offline)
|
|
374
|
-
|
|
375
|
-
:param id_list: list of volume ids, or a volume id
|
|
376
|
-
:type id_list: Union[List[str], str]
|
|
377
|
-
"""
|
|
378
|
-
payload = {
|
|
379
|
-
'id': id_list,
|
|
380
|
-
'action': VolumeActions.DELETE,
|
|
381
|
-
'is_permanent': is_permanent,
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
self._http_client.put(VOLUMES_ENDPOINT, json=payload)
|
|
385
|
-
return
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: datacrunch
|
|
3
|
-
Version: 1.16.0
|
|
4
|
-
Summary: Official Python SDK for DataCrunch Public API
|
|
5
|
-
Author: DataCrunch Oy
|
|
6
|
-
Author-email: DataCrunch Oy <info@datacrunch.io>
|
|
7
|
-
Classifier: Development Status :: 5 - Production/Stable
|
|
8
|
-
Classifier: Intended Audience :: Developers
|
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
-
Classifier: Natural Language :: English
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Classifier: Programming Language :: Python :: 3
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
-
Requires-Dist: requests>=2.25.1,<3
|
|
18
|
-
Requires-Dist: dataclasses-json>=0.6.7
|
|
19
|
-
Requires-Python: >=3.11
|
|
20
|
-
Project-URL: Changelog, https://datacrunch-python.readthedocs.io/en/latest/changelog.html
|
|
21
|
-
Project-URL: Documentation, https://datacrunch-python.readthedocs.io/
|
|
22
|
-
Project-URL: Homepage, https://github.com/DataCrunch-io
|
|
23
|
-
Project-URL: Repository, https://github.com/DataCrunch-io/datacrunch-python
|
|
24
|
-
Description-Content-Type: text/markdown
|
|
25
|
-
|
|
26
|
-
# DataCrunch Python SDK
|
|
27
|
-
|
|
28
|
-
[<img src='https://github.com/DataCrunch-io/datacrunch-python/workflows/Unit%20Tests/badge.svg'>](https://github.com/DataCrunch-io/datacrunch-python/actions?query=workflow%3A%22Unit+Tests%22+branch%3Amaster)
|
|
29
|
-
[<img src='https://github.com/DataCrunch-io/datacrunch-python/workflows/Code%20Style/badge.svg'>](https://github.com/DataCrunch-io/datacrunch-python/actions?query=workflow%3A%22Code+Style%22+branch%3Amaster)
|
|
30
|
-
[<img src="https://codecov.io/gh/DataCrunch-io/datacrunch-python/branch/master/graph/badge.svg?token=5X5KTYSSPK">](https://codecov.io/gh/DataCrunch-io/datacrunch-python)
|
|
31
|
-
[<img src='https://readthedocs.org/projects/datacrunch-python/badge/?version=latest'>](https://datacrunch-python.readthedocs.io/en/latest/)
|
|
32
|
-
[<img src='https://img.shields.io/github/license/DataCrunch-io/datacrunch-python'>](https://github.com/DataCrunch-io/datacrunch-python/blob/master/LICENSE)
|
|
33
|
-
[<img src='https://img.shields.io/pypi/v/datacrunch?logo=python'>](https://pypi.org/project/datacrunch/)
|
|
34
|
-
[<img src='https://img.shields.io/pypi/pyversions/datacrunch'>](https://pypi.org/project/datacrunch/)
|
|
35
|
-
|
|
36
|
-
The official [DataCrunch.io](https://datacrunch.io) Python SDK.
|
|
37
|
-
|
|
38
|
-
The SDK's documentation is available on [ReadTheDocs](https://datacrunch-python.readthedocs.io/en/latest/)
|
|
39
|
-
|
|
40
|
-
DataCrunch's Public API documentation [is available here](https://api.datacrunch.io/v1/docs).
|
|
41
|
-
|
|
42
|
-
## Getting Started - Using the SDK:
|
|
43
|
-
|
|
44
|
-
- Install:
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
# via pip
|
|
48
|
-
pip3 install datacrunch
|
|
49
|
-
|
|
50
|
-
# via uv
|
|
51
|
-
uv add datacrunch
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
- Generate your client credentials - [instructions in the public API docs](https://api.datacrunch.io/v1/docs#description/quick-start-guide).
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- Add your client id and client secret to an environment variable (don't want it to be hardcoded):
|
|
58
|
-
|
|
59
|
-
Linux (bash):
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
export DATACRUNCH_CLIENT_ID=YOUR_ID_HERE
|
|
63
|
-
export DATACRUNCH_CLIENT_SECRET=YOUR_SECRET_HERE
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
- To enable sending inference requests from SDK you must generate an inference key - [Instructions on inference authorization](https://docs.datacrunch.io/inference/authorization)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
- Add your inference key to an environment variable
|
|
70
|
-
|
|
71
|
-
Linux (bash):
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
export DATACRUNCH_INFERENCE_KEY=YOUR_API_KEY_HERE
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Other platforms:
|
|
78
|
-
https://en.wikipedia.org/wiki/Environment_variable
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
- Example for creating a new instance:
|
|
83
|
-
|
|
84
|
-
```python
|
|
85
|
-
import os
|
|
86
|
-
from datacrunch import DataCrunchClient
|
|
87
|
-
|
|
88
|
-
# Get credentials from environment variables
|
|
89
|
-
CLIENT_ID = os.environ.get('DATACRUNCH_CLIENT_ID')
|
|
90
|
-
CLIENT_SECRET = os.environ['DATACRUNCH_CLIENT_SECRET']
|
|
91
|
-
|
|
92
|
-
# Create datcrunch client
|
|
93
|
-
datacrunch = DataCrunchClient(CLIENT_ID, CLIENT_SECRET)
|
|
94
|
-
|
|
95
|
-
# Get all SSH keys
|
|
96
|
-
ssh_keys = datacrunch.ssh_keys.get()
|
|
97
|
-
ssh_keys = list(map(lambda key: key.id, ssh_keys))
|
|
98
|
-
|
|
99
|
-
# Create a new instance
|
|
100
|
-
instance = datacrunch.instances.create(instance_type='1V100.6V',
|
|
101
|
-
image='ubuntu-24.04-cuda-12.8-open-docker',
|
|
102
|
-
ssh_key_ids=ssh_keys,
|
|
103
|
-
hostname='example',
|
|
104
|
-
description='example instance')
|
|
105
|
-
|
|
106
|
-
# Delete instance
|
|
107
|
-
datacrunch.instances.action(instance.id, datacrunch.constants.instance_actions.DELETE)
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
More examples can be found in the `/examples` folder or in the [documentation](https://datacrunch-python.readthedocs.io/en/latest/).
|
|
111
|
-
|
|
112
|
-
## Development
|
|
113
|
-
|
|
114
|
-
### Set up the local development environment
|
|
115
|
-
|
|
116
|
-
Prerequisite: install [`uv`](https://docs.astral.sh/uv/).
|
|
117
|
-
|
|
118
|
-
Clone the repository, create local environment and install dependencies:
|
|
119
|
-
|
|
120
|
-
```bash
|
|
121
|
-
git clone git@github.com:DataCrunch-io/datacrunch-python.git
|
|
122
|
-
cd datacrunch-python
|
|
123
|
-
uv sync
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Run Tests
|
|
127
|
-
|
|
128
|
-
- Execute all tests
|
|
129
|
-
|
|
130
|
-
```bash
|
|
131
|
-
uv run pytest
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
- Execute a single test file
|
|
135
|
-
|
|
136
|
-
```bash
|
|
137
|
-
uv run pytest tests/unit_tests/test_file.py
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
### Local Manual Testing
|
|
141
|
-
|
|
142
|
-
Create a file in the root directory of the project:
|
|
143
|
-
|
|
144
|
-
```python
|
|
145
|
-
# example.py
|
|
146
|
-
from datacrunch.datacrunch import DataCrunchClient
|
|
147
|
-
|
|
148
|
-
CLIENT_SECRET = 'secret'
|
|
149
|
-
CLIENT_ID = 'your-id'
|
|
150
|
-
|
|
151
|
-
# Create datacrunch client
|
|
152
|
-
datacrunch = DataCrunchClient(CLIENT_ID, CLIENT_SECRET, base_url='http://localhost:3001/v1')
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
Run it:
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
uv run python example.py
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### Generating the documentation
|
|
162
|
-
|
|
163
|
-
If added a new service, create a documentation template under api/services for that service.
|
|
164
|
-
|
|
165
|
-
```bash
|
|
166
|
-
cd docs
|
|
167
|
-
make html
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
### Code style
|
|
171
|
-
|
|
172
|
-
```bash
|
|
173
|
-
# Lint
|
|
174
|
-
uv run ruff check
|
|
175
|
-
|
|
176
|
-
# Format code
|
|
177
|
-
uv run ruff format
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
## Contact
|
|
181
|
-
|
|
182
|
-
You can [contact us here](https://datacrunch.io/contact), or open an issue in the repo.
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
datacrunch/InferenceClient/__init__.py,sha256=oe7RQfoKbKJnIFWOt6TNtdzjXk5Gcl4-smO5DjLE6M0,117
|
|
2
|
-
datacrunch/InferenceClient/inference_client.py,sha256=GYjUshs2e2zKKw1B3KU8Dt2jr8kSt8QKRtML-Ce96GE,16907
|
|
3
|
-
datacrunch/__init__.py,sha256=ssI1WpIpRQhdwiO_3kYVtS7h9ePGZ5sgTyRieTYhllU,96
|
|
4
|
-
datacrunch/_version.py,sha256=5vv5w-bgsYeQlFvxgfqpdPWtyGiNYqDZyagqHmT6AwM,165
|
|
5
|
-
datacrunch/authentication/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
datacrunch/authentication/authentication.py,sha256=ksjcEKhx6xhbp86EnWuKHqHeFy7of_FAR7x1BS-hMbE,3508
|
|
7
|
-
datacrunch/balance/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
datacrunch/balance/balance.py,sha256=PT-d4JHCRiHJIk0K1Hi0v_R8CeDqa6000zfBSNV4nWE,1215
|
|
9
|
-
datacrunch/constants.py,sha256=p7l9xNByisNVlXwy2jQskCxI1zU9bbTtq1hYgGXz2QE,2432
|
|
10
|
-
datacrunch/containers/__init__.py,sha256=qNxgk3tS9Dx251ugXjmsDWeab2MO7EAFLd6aRo1XpmQ,744
|
|
11
|
-
datacrunch/containers/containers.py,sha256=RJnMsTtQqDbWC_i0GqdKuQDtuFtziPW2kiP13MYuIos,35775
|
|
12
|
-
datacrunch/datacrunch.py,sha256=U7kqcdt2hrG27M8a1dEbCWFo-eL_h71yMSX4vW-K2qA,3454
|
|
13
|
-
datacrunch/exceptions.py,sha256=uOP_YU2HEUi_mcMxQ9WYrIjqWUuUrwdube-RdL1C4Ps,781
|
|
14
|
-
datacrunch/helpers.py,sha256=OOG5B25q1tpDqa_6zen4C-nLEnPbI2sJGGC-btoZiRk,666
|
|
15
|
-
datacrunch/http_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
-
datacrunch/http_client/http_client.py,sha256=KjmAKhSgDFdps6Z4z2RqJIHpOannUkwQF8PvvntGHEM,8265
|
|
17
|
-
datacrunch/images/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
-
datacrunch/images/images.py,sha256=PmJZrX4qYAyeE4cwcfM2PWwNNN6aSFlAjEo578qP8h8,2260
|
|
19
|
-
datacrunch/instance_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
|
-
datacrunch/instance_types/instance_types.py,sha256=cHGLx5nSNGQhLL5WglJN5iYfUDoe9jSgzr9R7pwgIkk,5340
|
|
21
|
-
datacrunch/instances/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
-
datacrunch/instances/instances.py,sha256=VU7fxMFrT_x9u_xZP_WYrYR6U3Z6jSKlfODXL3KMODc,9813
|
|
23
|
-
datacrunch/locations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
|
-
datacrunch/locations/locations.py,sha256=tcmLrvyo6WaR-6YJ0Hr5vf_GqXjDzLTToybl5dYosgo,395
|
|
25
|
-
datacrunch/ssh_keys/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
-
datacrunch/ssh_keys/ssh_keys.py,sha256=YD9QnsvWAKC6i2RIxF9fo1u2Z9ayxj3jVZgyUxqvYVs,2894
|
|
27
|
-
datacrunch/startup_scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
|
-
datacrunch/startup_scripts/startup_scripts.py,sha256=vqEYOwRf2luaS_m0jrGbLtWu7HZpt-IfzXbhJ7DH_b8,3202
|
|
29
|
-
datacrunch/volume_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
|
-
datacrunch/volume_types/volume_types.py,sha256=KPNAUtvlZkYbX1IIBiAELVst8bU71v4MwztxLhKQHlI,1886
|
|
31
|
-
datacrunch/volumes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
32
|
-
datacrunch/volumes/volumes.py,sha256=UiuKBRv4dTEsJrEWSTMQyVurb9WZrLJy42pmYGmWL5o,11560
|
|
33
|
-
datacrunch-1.16.0.dist-info/WHEEL,sha256=M6du7VZflc4UPsGphmOXHANdgk8zessdJG0DBUuoA-U,78
|
|
34
|
-
datacrunch-1.16.0.dist-info/METADATA,sha256=momu6xw9SXypuLyhwtNfoHB6-0NYOMAuQBnuOFBPvqE,5673
|
|
35
|
-
datacrunch-1.16.0.dist-info/RECORD,,
|