Skip to content

Commit 12bd7b2

Browse files
committed
fall back to shadeform when cloud is excesssupply
1 parent 53c1bc2 commit 12bd7b2

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

v1/providers/shadeform/instancetype.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
const (
1919
UsdCurrentCode = "USD"
2020
AllRegions = "all"
21+
excessSupply = "excesssupply"
2122
)
2223

2324
// TODO: We need to apply a filter to specifically limit the integration and api to selected clouds and shade instance types
@@ -176,6 +177,7 @@ func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeform
176177

177178
gpuName := shadeformGPUTypeToBrevGPUName(shadeformInstanceType.Configuration.GpuType)
178179
gpuManufacturer := v1.GetManufacturer(shadeformInstanceType.Configuration.GpuManufacturer)
180+
cloud := shadeformCloud(shadeformInstanceType.Cloud)
179181

180182
for _, region := range shadeformInstanceType.Availability {
181183
instanceTypes = append(instanceTypes, v1.InstanceType{
@@ -205,7 +207,7 @@ func (c *ShadeformClient) convertShadeformInstanceTypeToV1InstanceType(shadeform
205207
IsAvailable: region.Available,
206208
Location: region.Region,
207209
Provider: CloudProviderID,
208-
Cloud: string(shadeformInstanceType.Cloud),
210+
Cloud: cloud,
209211
})
210212
}
211213

@@ -230,3 +232,16 @@ func shadeformGPUTypeToBrevGPUName(gpuType string) string {
230232
gpuType = strings.Split(gpuType, "_")[0]
231233
return gpuType
232234
}
235+
236+
func shadeformCloud(cloud openapi.Cloud) string {
237+
shadeformCloud := string(cloud)
238+
239+
// Shadeform will return the cloud as "excesssupply" if the instance type is retrieved
240+
// from cloud partners and not a direct cloud provider. In this case, we should just return
241+
// the Shadeform Cloud Provider ID.
242+
if strings.EqualFold(shadeformCloud, excessSupply) {
243+
return CloudProviderID
244+
}
245+
246+
return shadeformCloud
247+
}

0 commit comments

Comments
 (0)