feat(search): add gpu-search command to find GPU instance types#280
feat(search): add gpu-search command to find GPU instance types#280
Conversation
Add `brev search` command (aliases: gpu-search, gpu, gpus) to search and filter available GPU instance types across cloud providers. Features: - Filter by GPU name, provider, VRAM, compute capability, disk, boot time - Sort by price, vram, boot-time, etc. - Show instance features (stoppable, rebootable, flex-ports) - JSON output support for scripting - Pipeable output for chaining with other commands Examples: brev search --gpu-name A100 --sort price brev search --min-vram 40 --max-boot-time 5 brev search --json | jq '.[] | select(.price < 2)'
Manual QA Results ✅Build & Static Analysis:
Test Plan Verification:
Notes:
|
| return true // j unknown goes after i | ||
| } | ||
| less = instances[i].BootTime < instances[j].BootTime | ||
| default: |
There was a problem hiding this comment.
just a note that we silently fail if the sortBy string isn't valid (e.g. typo)
| ta.SetOutputMirror(os.Stdout) | ||
| ta.Style().Options = getBrevTableOptions() | ||
|
|
||
| header := table.Row{"TYPE", "TARGET_DISK", "PROVIDER", "GPU", "COUNT", "VRAM/GPU", "TOTAL_VRAM", "CAPABILITY", "DISK", "$/GB/MO", "BOOT", "FEATURES", "VCPUs", "$/HR"} |
There was a problem hiding this comment.
could extract a common
func formatInstanceRow(inst GPUInstanceInfo, colored bool, t *terminal.Terminal) table.Row {
// Common formatting logic
}
or something
your comment about colors doesn't seem to apply? I don't see where colors are being set.
| // parseToGB converts size/memory strings like "22GiB360MiB", "16TiB", "2TiB768GiB" to GB | ||
| func parseToGB(s string) float64 { | ||
| var totalGB float64 | ||
| re := regexp.MustCompile(`(\d+(?:\.\d+)?)\s*(TiB|TB|GiB|GB|MiB|MB)`) |
There was a problem hiding this comment.
this only needs to be compiled once not every time it's called
| var totalSeconds int | ||
|
|
||
| // Match hours | ||
| hRe := regexp.MustCompile(`(\d+)h`) |
There was a problem hiding this comment.
same with these don't need to compile every time
| if s.PricePerGBHr.Amount != "" { | ||
| pricePerHr, _ := strconv.ParseFloat(s.PricePerGBHr.Amount, 64) | ||
| if pricePerHr > 0 { | ||
| pricePerGBMonth = pricePerHr * 730 |
There was a problem hiding this comment.
magic number: make 730 a val called "hoursInMonth" ?
| ) | ||
|
|
||
| const ( | ||
| instanceTypesAPIURL = "https://api.brev.dev" |
There was a problem hiding this comment.
move this to pkg/config/config.go as "PUBLIC REST API", though I think we want to deprecate this in favor of the Connect/GRPC APIs directly. Unless this is an alias I don't know about.
I think there is a different https://brevapi2.us-west-2-prod.control-plane.brev.dev/api/public-instances endpoint that doesn't require Auth that @stephahart put in that the UI uses.
|
|
||
| // fetchInstanceTypes fetches instance types from the public Brev API | ||
| func fetchInstanceTypes() (*gpusearch.InstanceTypesResponse, error) { | ||
| client := resty.New() |
There was a problem hiding this comment.
why not use NewRestyClient?
Summary
Add
brev searchcommand (aliases:gpu-search,gpu,gpus) to search and filter available GPU instance types across cloud providers.Features
Examples
Test plan
brev searchshows available GPUs