Skip to content

Commit

Permalink
fix(bidengine): parse GPU interface
Browse files Browse the repository at this point in the history
- Update parseGPU function to handle 'interface' attribute for GPUs

fixes akash-network/support#216
  • Loading branch information
andy108369 committed Apr 25, 2024
1 parent c96d15b commit 137cd12
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
5 changes: 3 additions & 2 deletions bidengine/pricing.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,9 @@ type storageElement struct {
}

type gpuVendorAttributes struct {
Model string `json:"model"`
RAM *string `json:"ram,omitempty"`
Model string `json:"model"`
RAM *string `json:"ram,omitempty"`
Interface *string `json:"interface,omitempty"`
}

type gpuAttributes struct {
Expand Down
28 changes: 20 additions & 8 deletions bidengine/shellscript.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,30 @@ func parseGPU(resource *atypes.GPU) gpuElement {
case "vendor":
vendor := tokens[1]
model := tokens[3]
var ram *string

// vendor/nvidia/model/a100/ram/80Gi
if len(tokens) == 6 && tokens[4] == "ram" {
ram = new(string)
*ram = tokens[5]
}
tokens = tokens[4:]

res.Attributes.Vendor[vendor] = gpuVendorAttributes{
attrs := gpuVendorAttributes{
Model: model,
RAM: ram,
}

for i := 0; i < len(tokens); i += 2 {
key := tokens[i]
val := tokens[i+1]

switch key {
case "ram":
attrs.RAM = new(string)
*attrs.RAM = val
case "interface":
attrs.Interface = new(string)
*attrs.Interface = val
default:
continue
}
}

res.Attributes.Vendor[vendor] = attrs
default:
}
}
Expand Down

0 comments on commit 137cd12

Please sign in to comment.