datacrunch 1.7.0__py3-none-any.whl → 1.7.3__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/__version__.py +1 -1
- datacrunch/instances/instances.py +43 -5
- {datacrunch-1.7.0.dist-info → datacrunch-1.7.3.dist-info}/METADATA +14 -4
- {datacrunch-1.7.0.dist-info → datacrunch-1.7.3.dist-info}/RECORD +7 -7
- {datacrunch-1.7.0.dist-info → datacrunch-1.7.3.dist-info}/WHEEL +1 -1
- {datacrunch-1.7.0.dist-info → datacrunch-1.7.3.dist-info}/LICENSE +0 -0
- {datacrunch-1.7.0.dist-info → datacrunch-1.7.3.dist-info}/top_level.txt +0 -0
datacrunch/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = '1.7.
|
|
1
|
+
VERSION = '1.7.3'
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
from typing import List, Union, Optional, Dict
|
|
1
|
+
from typing import List, Union, Optional, Dict, Literal
|
|
2
2
|
from datacrunch.helpers import stringify_class_object_properties
|
|
3
3
|
from datacrunch.constants import Locations
|
|
4
4
|
|
|
5
5
|
INSTANCES_ENDPOINT = '/instances'
|
|
6
6
|
|
|
7
|
+
Contract = Literal['LONG_TERM', 'PAY_AS_YOU_GO', 'SPOT']
|
|
8
|
+
Pricing = Literal['DYNAMIC_PRICE', 'FIXED_PRICE']
|
|
7
9
|
|
|
8
10
|
class Instance:
|
|
9
11
|
"""An instance model class"""
|
|
@@ -27,7 +29,9 @@ class Instance:
|
|
|
27
29
|
gpu_memory: dict,
|
|
28
30
|
location: str = Locations.FIN_01,
|
|
29
31
|
startup_script_id: str = None,
|
|
30
|
-
is_spot: bool = False
|
|
32
|
+
is_spot: bool = False,
|
|
33
|
+
contract: Contract = None,
|
|
34
|
+
pricing: Pricing = None,
|
|
31
35
|
) -> None:
|
|
32
36
|
"""Initialize the instance object
|
|
33
37
|
|
|
@@ -89,6 +93,8 @@ class Instance:
|
|
|
89
93
|
self._os_volume_id = os_volume_id
|
|
90
94
|
self._gpu_memory = gpu_memory
|
|
91
95
|
self._is_spot = is_spot
|
|
96
|
+
self._contract = contract
|
|
97
|
+
self._pricing = pricing
|
|
92
98
|
|
|
93
99
|
@property
|
|
94
100
|
def id(self) -> str:
|
|
@@ -261,6 +267,24 @@ class Instance:
|
|
|
261
267
|
"""
|
|
262
268
|
return self._is_spot
|
|
263
269
|
|
|
270
|
+
@property
|
|
271
|
+
def contract(self) -> bool:
|
|
272
|
+
"""Get contract type
|
|
273
|
+
|
|
274
|
+
:return: contract type
|
|
275
|
+
:rtype: str
|
|
276
|
+
"""
|
|
277
|
+
return self._contract
|
|
278
|
+
|
|
279
|
+
@property
|
|
280
|
+
def pricing(self) -> bool:
|
|
281
|
+
"""Get pricing type
|
|
282
|
+
|
|
283
|
+
:return: pricing type
|
|
284
|
+
:rtype: str
|
|
285
|
+
"""
|
|
286
|
+
return self._pricing
|
|
287
|
+
|
|
264
288
|
def __str__(self) -> str:
|
|
265
289
|
"""Returns a string of the json representation of the instance
|
|
266
290
|
|
|
@@ -306,7 +330,9 @@ class InstancesService:
|
|
|
306
330
|
storage=instance_dict['storage'],
|
|
307
331
|
os_volume_id=instance_dict['os_volume_id'] if 'os_volume_id' in instance_dict else None,
|
|
308
332
|
gpu_memory=instance_dict['gpu_memory'] if 'gpu_memory' in instance_dict else None,
|
|
309
|
-
is_spot=instance_dict['is_spot'] if 'is_spot' in instance_dict else False
|
|
333
|
+
is_spot=instance_dict['is_spot'] if 'is_spot' in instance_dict else False,
|
|
334
|
+
contract=instance_dict['contract'] if 'contract' in instance_dict else False,
|
|
335
|
+
pricing=instance_dict['pricing'] if 'pricing' in instance_dict else False,
|
|
310
336
|
), instances_dict))
|
|
311
337
|
return instances
|
|
312
338
|
|
|
@@ -340,7 +366,9 @@ class InstancesService:
|
|
|
340
366
|
storage=instance_dict['storage'],
|
|
341
367
|
os_volume_id=instance_dict['os_volume_id'] if 'os_volume_id' in instance_dict else None,
|
|
342
368
|
gpu_memory=instance_dict['gpu_memory'] if 'gpu_memory' in instance_dict else None,
|
|
343
|
-
is_spot=instance_dict['is_spot'] if 'is_spot' in instance_dict else False
|
|
369
|
+
is_spot=instance_dict['is_spot'] if 'is_spot' in instance_dict else False,
|
|
370
|
+
contract=instance_dict['contract'] if 'contract' in instance_dict else False,
|
|
371
|
+
pricing=instance_dict['pricing'] if 'pricing' in instance_dict else False,
|
|
344
372
|
)
|
|
345
373
|
return instance
|
|
346
374
|
|
|
@@ -356,6 +384,8 @@ class InstancesService:
|
|
|
356
384
|
existing_volumes: List[str] = None,
|
|
357
385
|
os_volume: Dict = None,
|
|
358
386
|
is_spot: bool = False,
|
|
387
|
+
contract: Contract = None,
|
|
388
|
+
pricing: Pricing = None,
|
|
359
389
|
coupon: str = None) -> Instance:
|
|
360
390
|
"""Creates (deploys) a new instance
|
|
361
391
|
|
|
@@ -381,6 +411,10 @@ class InstancesService:
|
|
|
381
411
|
:type os_volume: Dict, optional
|
|
382
412
|
:param is_spot: Is spot instance
|
|
383
413
|
:type is_spot: bool, optional
|
|
414
|
+
:param pricing: Pricing type
|
|
415
|
+
:type pricing: str, optional
|
|
416
|
+
:param contract: Contract type
|
|
417
|
+
:type contract: str, optional
|
|
384
418
|
:param coupon: coupon code
|
|
385
419
|
:type coupon: str, optional
|
|
386
420
|
:return: the new instance object
|
|
@@ -398,8 +432,12 @@ class InstancesService:
|
|
|
398
432
|
"volumes": volumes,
|
|
399
433
|
"existing_volumes": existing_volumes,
|
|
400
434
|
"is_spot": is_spot,
|
|
401
|
-
"coupon": coupon
|
|
435
|
+
"coupon": coupon,
|
|
402
436
|
}
|
|
437
|
+
if contract:
|
|
438
|
+
payload['contract'] = contract
|
|
439
|
+
if pricing:
|
|
440
|
+
payload['pricing'] = pricing
|
|
403
441
|
id = self._http_client.post(INSTANCES_ENDPOINT, json=payload).text
|
|
404
442
|
instance = self.get_by_id(id)
|
|
405
443
|
return instance
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.2
|
|
2
2
|
Name: datacrunch
|
|
3
|
-
Version: 1.7.
|
|
3
|
+
Version: 1.7.3
|
|
4
4
|
Summary: Official Python SDK for DataCrunch Public API
|
|
5
5
|
Home-page: https://github.com/DataCrunch-io
|
|
6
6
|
Author: DataCrunch Oy
|
|
@@ -27,6 +27,16 @@ Requires-Dist: pytest<7,>=6.2.1; extra == "test"
|
|
|
27
27
|
Requires-Dist: pytest-cov<3,>=2.10.1; extra == "test"
|
|
28
28
|
Requires-Dist: pytest-responses<1,>=0.4.0; extra == "test"
|
|
29
29
|
Requires-Dist: responses<1,>=0.12.1; extra == "test"
|
|
30
|
+
Dynamic: author
|
|
31
|
+
Dynamic: author-email
|
|
32
|
+
Dynamic: classifier
|
|
33
|
+
Dynamic: description
|
|
34
|
+
Dynamic: description-content-type
|
|
35
|
+
Dynamic: home-page
|
|
36
|
+
Dynamic: provides-extra
|
|
37
|
+
Dynamic: requires-dist
|
|
38
|
+
Dynamic: requires-python
|
|
39
|
+
Dynamic: summary
|
|
30
40
|
|
|
31
41
|
# DataCrunch Python SDK
|
|
32
42
|
|
|
@@ -64,7 +74,7 @@ The official [DataCrunch.io](https://datacrunch.io) Python SDK.
|
|
|
64
74
|
|
|
65
75
|
The SDK's documentation is available on [ReadTheDocs](https://datacrunch-python.readthedocs.io/en/latest/)
|
|
66
76
|
|
|
67
|
-
DataCrunch's Public API documentation [is available here](https://datacrunch.
|
|
77
|
+
DataCrunch's Public API documentation [is available here](https://api.datacrunch.io/v1/docs).
|
|
68
78
|
|
|
69
79
|
## Getting Started - Using the SDK:
|
|
70
80
|
|
|
@@ -74,7 +84,7 @@ DataCrunch's Public API documentation [is available here](https://datacrunch.sto
|
|
|
74
84
|
pip3 install datacrunch
|
|
75
85
|
```
|
|
76
86
|
|
|
77
|
-
- Generate your client credentials - [instructions in the public API docs](https://datacrunch.
|
|
87
|
+
- Generate your client credentials - [instructions in the public API docs](https://api.datacrunch.io/v1/docs#description/quick-start-guide).
|
|
78
88
|
|
|
79
89
|
- Add the client secret to an environment variable (don't want it to be hardcoded):
|
|
80
90
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
datacrunch/__init__.py,sha256=OG-5Avmuq3NXyBs_66GMwyzscUi0c-T6vWW5sRIfnZg,51
|
|
2
|
-
datacrunch/__version__.py,sha256=
|
|
2
|
+
datacrunch/__version__.py,sha256=Zvj-6xERFc_YUDACDP6hhJTmnVDFA3Nx7fSqUgkGYxs,18
|
|
3
3
|
datacrunch/constants.py,sha256=uBtS1kTe6ip5oWzA4SKAVftdapkKwUU45GdLYOuBzAA,2354
|
|
4
4
|
datacrunch/datacrunch.py,sha256=dFSaeh1_xrfAc4lOqu1vGxxUtRpn7BdAbnW2mHKAHgU,2898
|
|
5
5
|
datacrunch/exceptions.py,sha256=uOP_YU2HEUi_mcMxQ9WYrIjqWUuUrwdube-RdL1C4Ps,781
|
|
@@ -15,7 +15,7 @@ datacrunch/images/images.py,sha256=hCAtSzozHcAAJ_UZOvnAbQSEU7BfCuixpIsmcd2RM2k,2
|
|
|
15
15
|
datacrunch/instance_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
datacrunch/instance_types/instance_types.py,sha256=NLkUI6UdfXg-zDkMu9j9RzVISLG8jdABhT_R7XpfBdA,5289
|
|
17
17
|
datacrunch/instances/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
|
-
datacrunch/instances/instances.py,sha256=
|
|
18
|
+
datacrunch/instances/instances.py,sha256=DAjFSQPwugN4_u-13Q9K4gyjrPYwdTrIw2exHwhJ1bw,16626
|
|
19
19
|
datacrunch/locations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
20
20
|
datacrunch/locations/locations.py,sha256=2f1OF2ObNaqGam_Mm0Btie1GymnAI9UzXulhqSSm7zo,404
|
|
21
21
|
datacrunch/ssh_keys/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -56,8 +56,8 @@ tests/unit_tests/volume_types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
|
|
|
56
56
|
tests/unit_tests/volume_types/test_volume_types.py,sha256=vGuC3dWjhQLD8bTYgw_we3dZ6vlUKRmKZbb9yCfhe0w,1386
|
|
57
57
|
tests/unit_tests/volumes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
58
|
tests/unit_tests/volumes/test_volumes.py,sha256=p53eSIHddWKL7U9oLLTnxo849LrJSoi6A5lpWF6ydHs,20672
|
|
59
|
-
datacrunch-1.7.
|
|
60
|
-
datacrunch-1.7.
|
|
61
|
-
datacrunch-1.7.
|
|
62
|
-
datacrunch-1.7.
|
|
63
|
-
datacrunch-1.7.
|
|
59
|
+
datacrunch-1.7.3.dist-info/LICENSE,sha256=LkdhbR2MArjDfV8M0dySL5mG_kfzxF2ntMgbJvWGyUQ,1069
|
|
60
|
+
datacrunch-1.7.3.dist-info/METADATA,sha256=yh2jdxqU8ZZgBkPD02jFNtGRTMkKHXb6wtRD23-xIIU,6076
|
|
61
|
+
datacrunch-1.7.3.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
|
62
|
+
datacrunch-1.7.3.dist-info/top_level.txt,sha256=FvH4EZJkbUxNm-aKx0RjmWwnduAMpfRT13Fo123i7yE,17
|
|
63
|
+
datacrunch-1.7.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|