Skip to content

Commit 273161c

Browse files
authored
maxTime flag propagates to Bacalhau Job.Spec.Timeout (#636)
1 parent e6cffcd commit 273161c

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

cmd/upgrade.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ var upgradeCmd = &cobra.Command{
3131
}
3232

3333
const (
34-
CurrentPlexVersion = "v0.10.2"
34+
CurrentPlexVersion = "v0.10.3"
3535
ReleaseURL = "https://api.github.com/repos/labdao/plex/releases/latest"
3636
ToolsURL = "https://api.github.com/repos/labdao/plex/contents/tools?ref=main"
3737
)

internal/bacalhau/bacalhau.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func GetBacalhauApiHost() string {
2727
}
2828
}
2929

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

4142
// had problems getting selector to work in bacalhau v0.28
4243
var selectorLabel string

internal/bacalhau/bacalhau_test.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,22 @@ import (
55
"testing"
66
)
77

8-
func TestCreateBalhauJob(t *testing.T) {
8+
func TestCreateBacalhauJob(t *testing.T) {
99
cid := "bafybeibuivbwkakim3hkgphffaipknuhw4epjfu3bstvsuv577spjhbvju"
1010
container := "ubuntu"
1111
cmd := "echo DeSci"
12+
maxTime := 60
13+
timeOut := maxTime * 60 // Bacalhau timeout is in seconds, so we need to multiply by 60
1214
memory := "12gb"
1315
gpu := "1"
1416
networkFlag := true
15-
job, err := CreateBacalhauJob(cid, container, cmd, 12, true, networkFlag, []string{})
17+
job, err := CreateBacalhauJob(cid, container, cmd, 60, 12, true, networkFlag, []string{})
1618
if err != nil {
1719
t.Fatalf(fmt.Sprint(err))
1820
}
21+
if job.Spec.Timeout != float64(timeOut) {
22+
t.Errorf("got = %f; wanted %d", job.Spec.Timeout, timeOut)
23+
}
1924
if job.Spec.Resources.Memory != memory {
2025
t.Errorf("got = %s; wanted %s", job.Spec.Resources.Memory, memory)
2126
}

internal/ipwl/ipwl.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ func processIOTask(ioEntry IO, index, maxTime int, jobDir, ioJsonPath string, re
157157
memory = *toolConfig.MemoryGB
158158
}
159159

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

0 commit comments

Comments
 (0)