Skip to content

Commit eda7cdf

Browse files
authored
Merge pull request #82 from imagene-shahar/master
Sync missing OpenAPI service groups
2 parents 7b0fb1a + f2465c3 commit eda7cdf

21 files changed

Lines changed: 757 additions & 14 deletions

File tree

datacrunch_compat/datacrunch/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
__version__,
66
authentication,
77
balance,
8+
cluster_types,
89
constants,
10+
container_types,
911
containers,
1012
exceptions,
1113
helpers,
1214
http_client,
1315
images,
1416
instance_types,
1517
instances,
18+
job_deployments,
1619
locations,
1720
ssh_keys,
1821
startup_scripts,
@@ -28,7 +31,9 @@
2831
'__version__',
2932
'authentication',
3033
'balance',
34+
'cluster_types',
3135
'constants',
36+
'container_types',
3237
'containers',
3338
'datacrunch',
3439
'exceptions',
@@ -37,6 +42,7 @@
3742
'images',
3843
'instance_types',
3944
'instances',
45+
'job_deployments',
4046
'locations',
4147
'ssh_keys',
4248
'startup_scripts',

datacrunch_compat/datacrunch/datacrunch.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
from verda._version import __version__
55
from verda.authentication import AuthenticationService
66
from verda.balance import BalanceService
7+
from verda.cluster_types import ClusterTypesService
78
from verda.constants import Constants
9+
from verda.container_types import ContainerTypesService
810
from verda.containers import ContainersService
911
from verda.http_client import HTTPClient
1012
from verda.images import ImagesService
1113
from verda.instance_types import InstanceTypesService
1214
from verda.instances import InstancesService
15+
from verda.job_deployments import JobDeploymentsService
1316
from verda.locations import LocationsService
1417
from verda.ssh_keys import SSHKeysService
1518
from verda.startup_scripts import StartupScriptsService
@@ -20,13 +23,16 @@
2023
__all__ = [
2124
'AuthenticationService',
2225
'BalanceService',
26+
'ClusterTypesService',
2327
'Constants',
28+
'ContainerTypesService',
2429
'ContainersService',
2530
'DataCrunchClient',
2631
'HTTPClient',
2732
'ImagesService',
2833
'InstanceTypesService',
2934
'InstancesService',
35+
'JobDeploymentsService',
3036
'LocationsService',
3137
'SSHKeysService',
3238
'StartupScriptsService',
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Cluster Types
2+
=============
3+
4+
.. autoclass:: verda.cluster_types.ClusterTypesService
5+
:members:
6+
7+
.. autoclass:: verda.cluster_types.ClusterType
8+
:members:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Container Types
2+
===============
3+
4+
.. autoclass:: verda.container_types.ContainerTypesService
5+
:members:
6+
7+
.. autoclass:: verda.container_types.ContainerType
8+
:members:
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Job Deployments
2+
===============
3+
4+
.. autoclass:: verda.job_deployments.JobDeploymentsService
5+
:members:
6+
7+
.. autoclass:: verda.job_deployments.JobDeployment
8+
:members:
9+
10+
.. autoclass:: verda.job_deployments.JobDeploymentSummary
11+
:members:
12+
13+
.. autoclass:: verda.job_deployments.JobScalingOptions
14+
:members:
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import responses # https://github.com/getsentry/responses
2+
3+
from verda.cluster_types import ClusterType, ClusterTypesService
4+
5+
CLUSTER_TYPE_ID = 'cluster-c0de-a5d2-4972-ae4e-d429115d055b'
6+
7+
8+
@responses.activate
9+
def test_cluster_types(http_client):
10+
endpoint = http_client._base_url + '/cluster-types?currency=usd'
11+
responses.add(
12+
responses.GET,
13+
endpoint,
14+
json=[
15+
{
16+
'id': CLUSTER_TYPE_ID,
17+
'model': 'H200',
18+
'name': 'H200 Cluster',
19+
'cluster_type': '16H200',
20+
'cpu': {'description': '64 CPU', 'number_of_cores': 64},
21+
'gpu': {'description': '16x H200', 'number_of_gpus': 16},
22+
'gpu_memory': {'description': '2.2TB VRAM', 'size_in_gigabytes': 2200},
23+
'memory': {'description': '4TB RAM', 'size_in_gigabytes': 4096},
24+
'price_per_hour': '45.50',
25+
'currency': 'usd',
26+
'manufacturer': 'NVIDIA',
27+
'node_details': ['2x 8 GPU nodes'],
28+
'supported_os': ['ubuntu-24.04-cuda-12.8-cluster'],
29+
}
30+
],
31+
status=200,
32+
)
33+
34+
service = ClusterTypesService(http_client)
35+
36+
cluster_types = service.get()
37+
cluster_type = cluster_types[0]
38+
39+
assert isinstance(cluster_types, list)
40+
assert len(cluster_types) == 1
41+
assert isinstance(cluster_type, ClusterType)
42+
assert cluster_type.id == CLUSTER_TYPE_ID
43+
assert cluster_type.model == 'H200'
44+
assert cluster_type.name == 'H200 Cluster'
45+
assert cluster_type.cluster_type == '16H200'
46+
assert cluster_type.price_per_hour == 45.5
47+
assert cluster_type.currency == 'usd'
48+
assert cluster_type.manufacturer == 'NVIDIA'
49+
assert cluster_type.node_details == ['2x 8 GPU nodes']
50+
assert cluster_type.supported_os == ['ubuntu-24.04-cuda-12.8-cluster']
51+
assert responses.assert_call_count(endpoint, 1) is True
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import responses # https://github.com/getsentry/responses
2+
3+
from verda.container_types import ContainerType, ContainerTypesService
4+
5+
CONTAINER_TYPE_ID = 'type-c0de-a5d2-4972-ae4e-d429115d055b'
6+
7+
8+
@responses.activate
9+
def test_container_types(http_client):
10+
endpoint = http_client._base_url + '/container-types?currency=eur'
11+
responses.add(
12+
responses.GET,
13+
endpoint,
14+
json=[
15+
{
16+
'id': CONTAINER_TYPE_ID,
17+
'model': 'H100',
18+
'name': 'H100 SXM5 80GB',
19+
'instance_type': '1H100.80S.22V',
20+
'cpu': {'description': '22 CPU', 'number_of_cores': 22},
21+
'gpu': {'description': '1x H100 SXM5 80GB', 'number_of_gpus': 1},
22+
'gpu_memory': {'description': '80GB GPU RAM', 'size_in_gigabytes': 80},
23+
'memory': {'description': '187GB RAM', 'size_in_gigabytes': 187},
24+
'serverless_price': '1.75',
25+
'serverless_spot_price': '0.87',
26+
'currency': 'eur',
27+
'manufacturer': 'NVIDIA',
28+
}
29+
],
30+
status=200,
31+
)
32+
33+
service = ContainerTypesService(http_client)
34+
35+
container_types = service.get(currency='eur')
36+
container_type = container_types[0]
37+
38+
assert isinstance(container_types, list)
39+
assert len(container_types) == 1
40+
assert isinstance(container_type, ContainerType)
41+
assert container_type.id == CONTAINER_TYPE_ID
42+
assert container_type.model == 'H100'
43+
assert container_type.name == 'H100 SXM5 80GB'
44+
assert container_type.instance_type == '1H100.80S.22V'
45+
assert container_type.serverless_price == 1.75
46+
assert container_type.serverless_spot_price == 0.87
47+
assert container_type.currency == 'eur'
48+
assert container_type.manufacturer == 'NVIDIA'
49+
assert responses.assert_call_count(endpoint, 1) is True

tests/unit_tests/instance_types/test_instance_types.py

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,36 @@
1414
STORAGE_DESCRIPTION = '1800GB NVME'
1515
STORAGE_SIZE = 1800
1616
INSTANCE_TYPE_DESCRIPTION = 'Dedicated Bare metal Server'
17+
BEST_FOR = ['Large model inference', 'Multi-GPU training']
18+
MODEL = 'V100'
19+
NAME = 'Tesla V100'
20+
P2P = '300 GB/s'
1721
PRICE_PER_HOUR = 5.0
1822
SPOT_PRICE_PER_HOUR = 2.5
23+
SERVERLESS_PRICE = 1.25
24+
SERVERLESS_SPOT_PRICE = 0.75
1925
INSTANCE_TYPE = '8V100.48M'
26+
CURRENCY = 'eur'
27+
MANUFACTURER = 'NVIDIA'
28+
DISPLAY_NAME = 'NVIDIA Tesla V100'
29+
SUPPORTED_OS = ['ubuntu-24.04-cuda-12.8-open-docker']
2030

2131

32+
@responses.activate
2233
def test_instance_types(http_client):
2334
# arrange - add response mock
2435
responses.add(
2536
responses.GET,
26-
http_client._base_url + '/instance-types',
37+
http_client._base_url + '/instance-types?currency=eur',
2738
json=[
2839
{
2940
'id': TYPE_ID,
41+
'best_for': BEST_FOR,
3042
'cpu': {
3143
'description': CPU_DESCRIPTION,
3244
'number_of_cores': NUMBER_OF_CORES,
3345
},
46+
'deploy_warning': 'Use updated drivers',
3447
'gpu': {
3548
'description': GPU_DESCRIPTION,
3649
'number_of_gpus': NUMBER_OF_GPUS,
@@ -48,9 +61,18 @@ def test_instance_types(http_client):
4861
'size_in_gigabytes': STORAGE_SIZE,
4962
},
5063
'description': INSTANCE_TYPE_DESCRIPTION,
64+
'model': MODEL,
65+
'name': NAME,
66+
'p2p': P2P,
5167
'price_per_hour': '5.00',
5268
'spot_price': '2.50',
69+
'serverless_price': '1.25',
70+
'serverless_spot_price': '0.75',
5371
'instance_type': INSTANCE_TYPE,
72+
'currency': CURRENCY,
73+
'manufacturer': MANUFACTURER,
74+
'display_name': DISPLAY_NAME,
75+
'supported_os': SUPPORTED_OS,
5476
}
5577
],
5678
status=200,
@@ -59,7 +81,7 @@ def test_instance_types(http_client):
5981
instance_types_service = InstanceTypesService(http_client)
6082

6183
# act
62-
instance_types = instance_types_service.get()
84+
instance_types = instance_types_service.get(currency='eur')
6385
instance_type = instance_types[0]
6486

6587
# assert
@@ -71,6 +93,17 @@ def test_instance_types(http_client):
7193
assert instance_type.price_per_hour == PRICE_PER_HOUR
7294
assert instance_type.spot_price_per_hour == SPOT_PRICE_PER_HOUR
7395
assert instance_type.instance_type == INSTANCE_TYPE
96+
assert instance_type.best_for == BEST_FOR
97+
assert instance_type.model == MODEL
98+
assert instance_type.name == NAME
99+
assert instance_type.p2p == P2P
100+
assert instance_type.currency == CURRENCY
101+
assert instance_type.manufacturer == MANUFACTURER
102+
assert instance_type.display_name == DISPLAY_NAME
103+
assert instance_type.supported_os == SUPPORTED_OS
104+
assert instance_type.deploy_warning == 'Use updated drivers'
105+
assert instance_type.serverless_price == SERVERLESS_PRICE
106+
assert instance_type.serverless_spot_price == SERVERLESS_SPOT_PRICE
74107
assert isinstance(instance_type.cpu, dict)
75108
assert isinstance(instance_type.gpu, dict)
76109
assert isinstance(instance_type.memory, dict)

0 commit comments

Comments
 (0)