-
Notifications
You must be signed in to change notification settings - Fork 631
/
Copy pathrunpod_catalog.py
94 lines (71 loc) · 3.69 KB
/
runpod_catalog.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
""" RunPod | Catalog
This module loads the service catalog file and can be used to
query instance types and pricing information for RunPod.
"""
import typing
from typing import Dict, List, Optional, Tuple, Union
from sky.clouds.service_catalog import common
from sky.utils import ux_utils
if typing.TYPE_CHECKING:
from sky.clouds import cloud
_df = common.read_catalog('runpod/vms.csv')
def instance_type_exists(instance_type: str) -> bool:
return common.instance_type_exists_impl(_df, instance_type)
def validate_region_zone(
region: Optional[str],
zone: Optional[str]) -> Tuple[Optional[str], Optional[str]]:
return common.validate_region_zone_impl('runpod', _df, region, zone)
def get_hourly_cost(instance_type: str,
use_spot: bool = False,
region: Optional[str] = None,
zone: Optional[str] = None) -> float:
"""Returns the cost, or the cheapest cost among all zones for spot."""
return common.get_hourly_cost_impl(_df, instance_type, use_spot, region,
zone)
def get_vcpus_mem_from_instance_type(
instance_type: str) -> Tuple[Optional[float], Optional[float]]:
return common.get_vcpus_mem_from_instance_type_impl(_df, instance_type)
def get_default_instance_type(cpus: Optional[str] = None,
memory: Optional[str] = None,
disk_tier: Optional[str] = None) -> Optional[str]:
del disk_tier # RunPod does not support disk tiers.
# NOTE: After expanding catalog to multiple entries, you may
# want to specify a default instance type or family.
return common.get_instance_type_for_cpus_mem_impl(_df, cpus, memory)
def get_accelerators_from_instance_type(
instance_type: str) -> Optional[Dict[str, Union[int, float]]]:
return common.get_accelerators_from_instance_type_impl(_df, instance_type)
def get_instance_type_for_accelerator(
acc_name: str,
acc_count: int,
cpus: Optional[str] = None,
memory: Optional[str] = None,
use_spot: bool = False,
region: Optional[str] = None,
zone: Optional[str] = None) -> Tuple[Optional[List[str]], List[str]]:
"""Returns a list of instance types that have the given accelerator."""
return common.get_instance_type_for_accelerator_impl(df=_df,
acc_name=acc_name,
acc_count=acc_count,
cpus=cpus,
memory=memory,
use_spot=use_spot,
region=region,
zone=zone)
def get_region_zones_for_instance_type(instance_type: str,
use_spot: bool) -> List['cloud.Region']:
df = _df[_df['InstanceType'] == instance_type]
return common.get_region_zones(df, use_spot)
def list_accelerators(
gpus_only: bool,
name_filter: Optional[str],
region_filter: Optional[str],
quantity_filter: Optional[int],
case_sensitive: bool = True,
all_regions: bool = False,
require_price: bool = True) -> Dict[str, List[common.InstanceTypeInfo]]:
"""Returns all instance types in RunPod offering GPUs."""
del require_price # Unused.
return common.list_accelerators_impl('RunPod', _df, gpus_only, name_filter,
region_filter, quantity_filter,
case_sensitive, all_regions)