Skip to content

Commit 2fc94f2

Browse files
authored
[Hot Aisle]: Store full VM specs in provider_data (#194)
Use the recently introduced `RawCatalogItem.provider_data` field to associate each catalog item with the full VM specs object. This allows us to drop the hardcoded specs from the dstack implementation,
1 parent 3edc18b commit 2fc94f2

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/gpuhunt/providers/hotaisle.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import logging
22
import os
3-
from typing import Optional
3+
from typing import Optional, TypedDict, cast
44

55
import requests
66
from requests import Response
77

88
from gpuhunt._internal.constraints import find_accelerators
9-
from gpuhunt._internal.models import AcceleratorVendor, QueryFilter, RawCatalogItem
9+
from gpuhunt._internal.models import AcceleratorVendor, JSONObject, QueryFilter, RawCatalogItem
1010
from gpuhunt.providers import AbstractProvider
1111

1212
logger = logging.getLogger(__name__)
@@ -53,6 +53,10 @@ def _make_request(self, method: str, url: str) -> Response:
5353
return response
5454

5555

56+
class HotAisleCatalogItemProviderData(TypedDict):
57+
vm_specs: JSONObject
58+
59+
5660
def get_gpu_memory(gpu_name: str) -> Optional[float]:
5761
if accelerators := find_accelerators(names=[gpu_name], vendors=[AcceleratorVendor.AMD]):
5862
return float(accelerators[0].memory)
@@ -96,6 +100,14 @@ def convert_response_to_raw_catalog_items(response: Response) -> list[RawCatalog
96100
gpu_vendor=gpu_vendor,
97101
spot=False,
98102
disk_size=disk_gb,
103+
provider_data=cast(
104+
JSONObject,
105+
HotAisleCatalogItemProviderData(
106+
# The specs object may duplicate some RawCatalogItem fields, but we store it in
107+
# full because we need to pass it back to the API when creating VMs.
108+
vm_specs=specs,
109+
),
110+
),
99111
)
100112
offers.append(offer)
101113

0 commit comments

Comments
 (0)