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

feat and fix: add gpuCount argument to StartSpotPod #157

Merged
merged 1 commit into from
Oct 6, 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
6 changes: 3 additions & 3 deletions api/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,19 +355,19 @@ func StartOnDemandPod(id string) (pod map[string]interface{}, err error) {
return
}

func StartSpotPod(id string, bidPerGpu float32) (podBidResume map[string]interface{}, err error) {
func StartSpotPod(id string, bidPerGpu float32, gpuCount int) (podBidResume map[string]interface{}, err error) {
input := Input{
Query: `
mutation Mutation($podId: String!, $bidPerGpu: Float!) {
podBidResume(input: {podId: $podId, bidPerGpu: $bidPerGpu}) {
podBidResume(input: {podId: $podId, bidPerGpu: $bidPerGpu, gpuCount: $gpuCount}) {
id
costPerHr
desiredStatus
lastStatusChange
}
}
`,
Variables: map[string]interface{}{"podId": id, "bidPerGpu": bidPerGpu},
Variables: map[string]interface{}{"podId": id, "bidPerGpu": bidPerGpu, "gpuCount": gpuCount},
}
res, err := Query(input)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion cmd/pod/startPod.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
)

var bidPerGpu float32
var gpuCount int

var StartPodCmd = &cobra.Command{
Use: "pod [podId]",
Expand All @@ -19,7 +20,7 @@ var StartPodCmd = &cobra.Command{
var err error
var pod map[string]interface{}
if bidPerGpu > 0 {
pod, err = api.StartSpotPod(args[0], bidPerGpu)
pod, err = api.StartSpotPod(args[0], bidPerGpu, gpuCount)
} else {
pod, err = api.StartOnDemandPod(args[0])
}
Expand All @@ -36,4 +37,5 @@ var StartPodCmd = &cobra.Command{

func init() {
StartPodCmd.Flags().Float32Var(&bidPerGpu, "bid", 0, "bid per gpu for spot price")
StartPodCmd.Flags().IntVar(&gpuCount, "gpuCount", 1, "number of GPUs to request")
}