Skip to content

Commit 53ecf61

Browse files
committed
air: trust backend compute options
1 parent b309133 commit 53ecf61

3 files changed

Lines changed: 13 additions & 29 deletions

File tree

‎cmd/air/run.go‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
const dryRunValidationTimeout = 15 * time.Second
2626

2727
// Bounds the workspace lookup performed by config help.
28-
const computeOptionsHelpTimeout = 5 * time.Second
28+
const computeOptionsHelpTimeout = 3 * time.Second
2929

3030
// runResult is the JSON payload for `air run`.
3131
type runResult struct {
@@ -295,10 +295,8 @@ func loadComputeOptionsForHelp(cmd *cobra.Command, args []string) []computeOptio
295295
}
296296
return fallbackComputeOptions()
297297
}
298-
options = filterKnownComputeOptions(options)
299-
if len(options) == 0 {
300-
cmd.PrintErrln("Warning: the workspace reported no supported accelerator types; showing the built-in list instead")
301-
return fallbackComputeOptions()
298+
if options == nil {
299+
return []computeOption{}
302300
}
303301
return options
304302
}

‎cmd/air/runconfig.go‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -862,8 +862,11 @@ func renderConfigField(w io.Writer, f configField, computeOptions []computeOptio
862862
if f.help != "" {
863863
fmt.Fprintf(w, " %s\n", f.help)
864864
}
865-
if f.path == "config.compute" && len(computeOptions) > 0 {
865+
if f.path == "config.compute" && computeOptions != nil {
866866
fmt.Fprintln(w, "\n Supported accelerator types:")
867+
if len(computeOptions) == 0 {
868+
fmt.Fprintln(w, " No accelerator types are currently available in this workspace.")
869+
}
867870
for _, option := range computeOptions {
868871
fmt.Fprintf(w, " %s - %s%s\n", option.HardwareAccelerator, formatPerNodeAcceleratorCount(option), launchStageBadge(option.LaunchStage))
869872
}
@@ -896,16 +899,6 @@ func renderConfigField(w io.Writer, f configField, computeOptions []computeOptio
896899
fmt.Fprintf(w, "\nUse \"-h %s.<field>\" for details on a field.\n", f.path)
897900
}
898901

899-
func filterKnownComputeOptions(options []computeOption) []computeOption {
900-
result := make([]computeOption, 0, len(options))
901-
for _, option := range options {
902-
if _, err := parseGPUType(option.HardwareAccelerator); err == nil {
903-
result = append(result, option)
904-
}
905-
}
906-
return result
907-
}
908-
909902
func fallbackComputeOptions() []computeOption {
910903
options := make([]computeOption, 0, len(gpuTypes))
911904
for _, acceleratorType := range gpuTypes {

‎cmd/air/runconfig_test.go‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -773,25 +773,18 @@ func TestRunCommandHelpComputeOptions(t *testing.T) {
773773
}{
774774
{
775775
name: "workspace subset",
776-
response: `{"compute_options":[{"hardware_accelerator":"GPU_8xH100","per_node_accelerator_count":4,"launch_stage":"PUBLIC_PREVIEW"},{"hardware_accelerator":"GPU_UNKNOWN"},{"hardware_accelerator":"GPU_1xA10"}]}`,
777-
wantOptions: " GPU_8xH100 - 4 accelerators per node [Public Preview]\n GPU_1xA10 - 1 accelerator per node",
776+
response: `{"compute_options":[{"hardware_accelerator":"GPU_8xH100","per_node_accelerator_count":4,"launch_stage":"PUBLIC_PREVIEW"},{"hardware_accelerator":"GPU_FUTURE","per_node_accelerator_count":16},{"hardware_accelerator":"GPU_1xA10"}]}`,
777+
wantOptions: " GPU_8xH100 - 4 accelerators per node [Public Preview]\n GPU_FUTURE - 16 accelerators per node\n GPU_1xA10 - 1 accelerator per node",
778778
},
779779
{
780-
name: "empty response falls back",
780+
name: "empty response",
781781
response: `{}`,
782-
wantOptions: builtInOptions,
783-
wantWarning: true,
784-
},
785-
{
786-
name: "disabled endpoint falls back",
787-
statusCode: http.StatusBadRequest,
788-
response: `{"error_code":"FEATURE_DISABLED","message":"ListComputeOptions is not yet enabled."}`,
789-
wantOptions: builtInOptions,
782+
wantOptions: " No accelerator types are currently available in this workspace.",
790783
},
791784
{
792-
name: "missing endpoint falls back",
785+
name: "endpoint unavailable falls back",
793786
statusCode: http.StatusNotFound,
794-
response: `{"error_code":"ENDPOINT_NOT_FOUND","message":"Not found."}`,
787+
response: `{"error_code":"NOT_FOUND","message":"ListComputeOptions is not yet enabled."}`,
795788
wantOptions: builtInOptions,
796789
},
797790
{

0 commit comments

Comments
 (0)