Skip to content

Commit

Permalink
Use cudo provider without credentials (#39)
Browse files Browse the repository at this point in the history
* Add CudoCompute provider

Added cudocompute in OFFLINE PROVIDERS

Removed dist directory

Cudocompute disksize set to None

* Fixed Review Issues and Added Integrity Tests for Cudo

* Bump checkout action from v3 to v4 for cudo

* Adjust Spacing With Pre-Commit for Cudo

* Remove cudo-compute python client

---------

Co-authored-by: Bihan  Rana <[email protected]>
  • Loading branch information
Bihan and Bihan Rana authored Feb 26, 2024
1 parent 84f1a73 commit dc45da6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 40 deletions.
41 changes: 18 additions & 23 deletions .github/workflows/catalogs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ jobs:
path: azure.csv
retention-days: 1

catalog-cudo:
name: Collect Cudo catalog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Collect catalog
working-directory: src
run: python -m gpuhunt cudo --output ../cudo.csv
- uses: actions/upload-artifact@v4
with:
name: catalogs-cudo
path: cudo.csv
retention-days: 1

catalog-datacrunch:
name: Collect DataCrunch catalog
runs-on: ubuntu-latest
Expand All @@ -87,7 +104,6 @@ jobs:
path: datacrunch.csv
retention-days: 1


catalog-gcp:
name: Collect GCP catalog
runs-on: ubuntu-latest
Expand Down Expand Up @@ -168,37 +184,16 @@ jobs:
path: nebius.csv
retention-days: 1

catalog-cudo:
name: Collect Cudo catalog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
run: |
pip install pip -U
pip install -e '.[cudo]'
- name: Collect catalog
working-directory: src
run: python -m gpuhunt cudo --output ../cudo.csv
- uses: actions/upload-artifact@v4
with:
name: catalogs-cudo
path: cudo.csv
retention-days: 1

test-catalog:
name: Test catalogs integrity
needs:
- catalog-aws
- catalog-azure
- catalog-cudo
- catalog-datacrunch
- catalog-gcp
- catalog-lambdalabs
- catalog-nebius
- catalog-cudo
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ nebius = [
datacrunch = [
"datacrunch"
]
cudo = [
"cudo_compute"
]
all = ["gpuhunt[aws,azure,cudo,datacrunch,gcp,nebius]"]
all = ["gpuhunt[aws,azure,datacrunch,gcp,nebius]"]
dev = [
"pre-commit",
"isort~=5.0",
Expand Down
34 changes: 21 additions & 13 deletions src/gpuhunt/providers/cudo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from itertools import chain
from typing import List, Optional

from cudo_compute import cudo_api
import requests

from gpuhunt import QueryFilter, RawCatalogItem
from gpuhunt._internal.constraints import KNOWN_GPUS
Expand All @@ -13,6 +13,8 @@
CpuMemoryGpu = namedtuple("CpuMemoryGpu", ["cpu", "memory", "gpu"])
logger = logging.getLogger(__name__)

API_URL = "https://rest.compute.cudo.org/v1"


class CudoProvider(AbstractProvider):
NAME = "cudo"
Expand Down Expand Up @@ -42,33 +44,39 @@ def fetch_all_vm_types(self):

def get_raw_catalog_list(self, vm_machine_type_list, vcpu, memory, gpu):
raw_list = []
for vm in vm_machine_type_list.host_configs:
for vm in vm_machine_type_list:
raw = RawCatalogItem(
instance_name=vm.machine_type,
location=vm.data_center_id,
instance_name=vm["machineType"],
location=vm["dataCenterId"],
spot=False,
price=round(
(float(vm.total_price_hr.value) + float(vm.storage_gib_price_hr.value)), 5
),
price=round(float(vm["totalPriceHr"]["value"]), 5),
cpu=vcpu,
memory=memory,
gpu_count=gpu,
gpu_name=gpu_name(vm.gpu_model),
gpu_memory=get_memory(gpu_name(vm.gpu_model)),
gpu_name=vm["gpuModel"],
gpu_memory=get_memory(gpu_name(vm["gpuModel"])),
disk_size=None,
)
raw_list.append(raw)
return raw_list

def fetch_vm_type(self, vcpu, memory_gib, gpu):
try:
result = cudo_api.virtual_machines().list_vm_machine_types(
vcpu=vcpu, memory_gib=memory_gib, gpu=gpu
)
result = self._list_vm_machine_types(vcpu, memory_gib, gpu)
return self.get_raw_catalog_list(result, vcpu, memory_gib, gpu)
except Exception as e:
except requests.HTTPError as e:
raise VMTypeFetchError(f"Failed to fetch VM type: {e}", vcpu, memory_gib, gpu)

def _list_vm_machine_types(self, vcpu, memory_gib, gpu):
resp = requests.request(
method="GET",
url=f"{API_URL}/vms/machine-types?vcpu={vcpu}&memory_gib={memory_gib}&gpu={gpu}",
)
if resp.ok:
data = resp.json()
return data["hostConfigs"]
resp.raise_for_status()


class VMTypeFetchError(Exception):
def __init__(self, message, vcpu, memory_gib, gpu):
Expand Down

0 comments on commit dc45da6

Please sign in to comment.