Skip to content

Commit e90f76a

Browse files
committed
feat(search): add cpu subcommand and wide mode to brev search
Restructure `brev search` into gpu/cpu subcommands: - `brev search` / `brev search gpu` - GPU instances (default, backwards compatible) - `brev search gpu --wide` - GPU instances with RAM and ARCH columns - `brev search cpu` - CPU-only instances via ?include_cpu=true API param CPU search has dedicated columns (TYPE, PROVIDER, VCPUs, RAM, ARCH, DISK, $/GB/MO, BOOT, FEATURES, $/HR) and filters (--min-ram, --arch). Shared filters (--provider, --min-vcpu, --min-disk, --max-boot-time, --stoppable, --rebootable, --flex-ports, --sort) work across both modes. Piping into `brev create` works for both GPU and CPU table output.
1 parent 6aece4f commit e90f76a

5 files changed

Lines changed: 559 additions & 144 deletions

File tree

pkg/cmd/gpucreate/gpucreate.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ func parseStartupScript(value string) (string, error) {
292292

293293
// searchInstances fetches and filters GPU instances using user-provided filters merged with defaults
294294
func searchInstances(s GPUCreateStore, filters *searchFilterFlags) ([]gpusearch.GPUInstanceInfo, float64, error) {
295-
response, err := s.GetInstanceTypes()
295+
response, err := s.GetInstanceTypes(false)
296296
if err != nil {
297297
return nil, 0, breverrors.WrapAndTrace(err)
298298
}
@@ -315,7 +315,7 @@ func searchInstances(s GPUCreateStore, filters *searchFilterFlags) ([]gpusearch.
315315

316316
instances := gpusearch.ProcessInstances(response.Items)
317317
filtered := gpusearch.FilterInstances(instances, filters.gpuName, filters.provider, filters.minVRAM,
318-
minTotalVRAM, minCapability, minDisk, maxBootTime, filters.stoppable, filters.rebootable, filters.flexPorts)
318+
minTotalVRAM, minCapability, minDisk, 0, maxBootTime, filters.stoppable, filters.rebootable, filters.flexPorts, true)
319319
gpusearch.SortInstances(filtered, sortBy, filters.descending)
320320

321321
return filtered, minDisk, nil
@@ -349,7 +349,7 @@ func runDryRun(t *terminal.Terminal, s GPUCreateStore, filters *searchFilterFlag
349349
}
350350

351351
piped := gpusearch.IsStdoutPiped()
352-
if err := gpusearch.DisplayResults(t, filtered, false, piped); err != nil {
352+
if err := gpusearch.DisplayGPUResults(t, filtered, false, piped, false); err != nil {
353353
return breverrors.WrapAndTrace(err)
354354
}
355355
return nil

pkg/cmd/gpucreate/gpucreate_test.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ func (m *MockGPUCreateStore) GetAllInstanceTypesWithWorkspaceGroups(orgID string
9797
return nil, nil
9898
}
9999

100-
func (m *MockGPUCreateStore) GetInstanceTypes() (*gpusearch.InstanceTypesResponse, error) {
100+
func (m *MockGPUCreateStore) GetInstanceTypes(_ bool) (*gpusearch.InstanceTypesResponse, error) {
101101
// Return a default set of instance types for testing
102102
return &gpusearch.InstanceTypesResponse{
103103
Items: []gpusearch.InstanceType{
@@ -355,6 +355,28 @@ func TestParseTableInput(t *testing.T) {
355355
assert.Equal(t, 1000.0, specs[2].DiskGB)
356356
}
357357

358+
func TestParseTableInputCPU(t *testing.T) {
359+
// Simulated plain table output from `brev search cpu`
360+
tableInput := strings.Join([]string{
361+
" TYPE TARGET_DISK PROVIDER VCPUS RAM ARCH DISK $/GB/MO BOOT FEATURES $/HR",
362+
" n2d-highcpu-2 10 gcp 2 2 x86_64 10GB-16TB $0.13 7m SP $0.05",
363+
" n1-standard-1 10 gcp 1 4 x86_64 10GB-16TB $0.14 7m SP $0.06",
364+
" m8i-flex.8xlarge 500 aws 32 128 x86_64 10GB-16TB $0.10 7m SRP $1.93",
365+
"",
366+
"Found 3 CPU instance types",
367+
}, "\n")
368+
369+
specs := parseTableInput(tableInput)
370+
371+
assert.Len(t, specs, 3)
372+
assert.Equal(t, "n2d-highcpu-2", specs[0].Type)
373+
assert.Equal(t, 10.0, specs[0].DiskGB)
374+
assert.Equal(t, "n1-standard-1", specs[1].Type)
375+
assert.Equal(t, 10.0, specs[1].DiskGB)
376+
assert.Equal(t, "m8i-flex.8xlarge", specs[2].Type)
377+
assert.Equal(t, 500.0, specs[2].DiskGB)
378+
}
379+
358380
func TestParseJSONInput(t *testing.T) {
359381
// Simulated JSON output from gpu-search --json
360382
jsonInput := `[

0 commit comments

Comments
 (0)