From 137cd12ff92757b37feed6cccab30b6c1d0d29ff Mon Sep 17 00:00:00 2001 From: Andrey Arapov Date: Wed, 24 Apr 2024 19:10:45 +0200 Subject: [PATCH] fix(bidengine): parse GPU interface - Update parseGPU function to handle 'interface' attribute for GPUs fixes akash-network/support#216 --- bidengine/pricing.go | 5 +++-- bidengine/shellscript.go | 28 ++++++++++++++++++++-------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/bidengine/pricing.go b/bidengine/pricing.go index 69c8a9b4..7804da60 100644 --- a/bidengine/pricing.go +++ b/bidengine/pricing.go @@ -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 { diff --git a/bidengine/shellscript.go b/bidengine/shellscript.go index 0edbc5da..47c163b9 100644 --- a/bidengine/shellscript.go +++ b/bidengine/shellscript.go @@ -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: } }