Skip to content
Open
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
8 changes: 4 additions & 4 deletions pkg/cmd/gpucreate/gpucreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ func parseStartupScript(value string) (string, error) {

// searchInstances fetches and filters GPU instances using user-provided filters merged with defaults
func searchInstances(s GPUCreateStore, filters *searchFilterFlags) ([]gpusearch.GPUInstanceInfo, float64, error) {
response, err := s.GetInstanceTypes()
response, err := s.GetInstanceTypes(false)
if err != nil {
return nil, 0, breverrors.WrapAndTrace(err)
}
Expand All @@ -314,8 +314,8 @@ func searchInstances(s GPUCreateStore, filters *searchFilterFlags) ([]gpusearch.
}

instances := gpusearch.ProcessInstances(response.Items)
filtered := gpusearch.FilterInstances(instances, filters.gpuName, filters.provider, filters.minVRAM,
minTotalVRAM, minCapability, minDisk, maxBootTime, filters.stoppable, filters.rebootable, filters.flexPorts)
filtered := gpusearch.FilterInstances(instances, filters.gpuName, filters.provider, "", filters.minVRAM,
minTotalVRAM, minCapability, 0, minDisk, 0, maxBootTime, filters.stoppable, filters.rebootable, filters.flexPorts, true)
gpusearch.SortInstances(filtered, sortBy, filters.descending)

return filtered, minDisk, nil
Expand Down Expand Up @@ -349,7 +349,7 @@ func runDryRun(t *terminal.Terminal, s GPUCreateStore, filters *searchFilterFlag
}

piped := gpusearch.IsStdoutPiped()
if err := gpusearch.DisplayResults(t, filtered, false, piped); err != nil {
if err := gpusearch.DisplayGPUResults(t, filtered, false, piped, false); err != nil {
return breverrors.WrapAndTrace(err)
}
return nil
Expand Down
24 changes: 23 additions & 1 deletion pkg/cmd/gpucreate/gpucreate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func (m *MockGPUCreateStore) GetAllInstanceTypesWithWorkspaceGroups(orgID string
return nil, nil
}

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

func TestParseTableInputCPU(t *testing.T) {
// Simulated plain table output from `brev search cpu`
tableInput := strings.Join([]string{
" TYPE TARGET_DISK PROVIDER VCPUS RAM ARCH DISK $/GB/MO BOOT FEATURES $/HR",
" n2d-highcpu-2 10 gcp 2 2 x86_64 10GB-16TB $0.13 7m SP $0.05",
" n1-standard-1 10 gcp 1 4 x86_64 10GB-16TB $0.14 7m SP $0.06",
" m8i-flex.8xlarge 500 aws 32 128 x86_64 10GB-16TB $0.10 7m SRP $1.93",
"",
"Found 3 CPU instance types",
}, "\n")

specs := parseTableInput(tableInput)

assert.Len(t, specs, 3)
assert.Equal(t, "n2d-highcpu-2", specs[0].Type)
assert.Equal(t, 10.0, specs[0].DiskGB)
assert.Equal(t, "n1-standard-1", specs[1].Type)
assert.Equal(t, 10.0, specs[1].DiskGB)
assert.Equal(t, "m8i-flex.8xlarge", specs[2].Type)
assert.Equal(t, 500.0, specs[2].DiskGB)
}

func TestParseJSONInput(t *testing.T) {
// Simulated JSON output from gpu-search --json
jsonInput := `[
Expand Down
Loading
Loading