Skip to content

Commit

Permalink
maxTime flag propagates to Bacalhau Job.Spec.Timeout (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
acashmoney authored Sep 7, 2023
1 parent e6cffcd commit 273161c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var upgradeCmd = &cobra.Command{
}

const (
CurrentPlexVersion = "v0.10.2"
CurrentPlexVersion = "v0.10.3"
ReleaseURL = "https://api.github.com/repos/labdao/plex/releases/latest"
ToolsURL = "https://api.github.com/repos/labdao/plex/contents/tools?ref=main"
)
Expand Down
3 changes: 2 additions & 1 deletion internal/bacalhau/bacalhau.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func GetBacalhauApiHost() string {
}
}

func CreateBacalhauJob(cid, container, cmd string, memory int, gpu, network bool, annotations []string) (job *model.Job, err error) {
func CreateBacalhauJob(cid, container, cmd string, maxTime, memory int, gpu, network bool, annotations []string) (job *model.Job, err error) {
job, err = model.NewJobWithSaneProductionDefaults()
if err != nil {
return nil, err
Expand All @@ -37,6 +37,7 @@ func CreateBacalhauJob(cid, container, cmd string, memory int, gpu, network bool
job.Spec.Publisher = model.PublisherIpfs
job.Spec.Docker.Entrypoint = []string{"/bin/bash", "-c", cmd}
job.Spec.Annotations = annotations
job.Spec.Timeout = float64(maxTime) * 60

// had problems getting selector to work in bacalhau v0.28
var selectorLabel string
Expand Down
9 changes: 7 additions & 2 deletions internal/bacalhau/bacalhau_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,22 @@ import (
"testing"
)

func TestCreateBalhauJob(t *testing.T) {
func TestCreateBacalhauJob(t *testing.T) {
cid := "bafybeibuivbwkakim3hkgphffaipknuhw4epjfu3bstvsuv577spjhbvju"
container := "ubuntu"
cmd := "echo DeSci"
maxTime := 60
timeOut := maxTime * 60 // Bacalhau timeout is in seconds, so we need to multiply by 60
memory := "12gb"
gpu := "1"
networkFlag := true
job, err := CreateBacalhauJob(cid, container, cmd, 12, true, networkFlag, []string{})
job, err := CreateBacalhauJob(cid, container, cmd, 60, 12, true, networkFlag, []string{})
if err != nil {
t.Fatalf(fmt.Sprint(err))
}
if job.Spec.Timeout != float64(timeOut) {
t.Errorf("got = %f; wanted %d", job.Spec.Timeout, timeOut)
}
if job.Spec.Resources.Memory != memory {
t.Errorf("got = %s; wanted %s", job.Spec.Resources.Memory, memory)
}
Expand Down
2 changes: 1 addition & 1 deletion internal/ipwl/ipwl.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func processIOTask(ioEntry IO, index, maxTime int, jobDir, ioJsonPath string, re
memory = *toolConfig.MemoryGB
}

bacalhauJob, err := bacalhau.CreateBacalhauJob(cid, toolConfig.DockerPull, cmd, memory, toolConfig.GpuBool, toolConfig.NetworkBool, annotations)
bacalhauJob, err := bacalhau.CreateBacalhauJob(cid, toolConfig.DockerPull, cmd, maxTime, memory, toolConfig.GpuBool, toolConfig.NetworkBool, annotations)
if err != nil {
updateIOWithError(ioJsonPath, index, err, fileMutex)
return fmt.Errorf("error creating Bacalhau job: %w", err)
Expand Down

0 comments on commit 273161c

Please sign in to comment.