Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bidengine): parse GPU interface #234

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading