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

Remove re-indexing code #34

Merged
merged 2 commits into from
Dec 12, 2024
Merged
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
19 changes: 0 additions & 19 deletions build/builder.go
Original file line number Diff line number Diff line change
@@ -168,9 +168,6 @@ type Builder struct {
mu sync.Mutex
runningEnvironments map[string]bool

postBuildMu sync.RWMutex
postBuild func()

statusMu sync.RWMutex
statuses map[string]*Status

@@ -216,14 +213,6 @@ type templateVars struct {
Packages []core.Package
}

// SetPostBuildCallback causes the passed callback to be called after the
// spack-related parts of a build have completed.
func (b *Builder) SetPostBuildCallback(cb func()) {
b.postBuildMu.Lock()
defer b.postBuildMu.Unlock()
b.postBuild = cb
}

// Status returns the status of all known builds.
func (b *Builder) Status() []Status {
b.statusMu.RLock()
@@ -391,14 +380,6 @@ func (b *Builder) asyncBuild(def *Definition, wrInput, s3Path, singDef string) e
status.BuildDone = &buildDone
b.statusMu.Unlock()

b.postBuildMu.RLock()
if b.postBuild != nil {
// if spack ran at all, it might've pushed things to the cache, even if
// it didn't succeed or if later steps don't run
go b.postBuild()
}
b.postBuildMu.RUnlock()

if err != nil || wrStatus != wr.WRJobStatusComplete {
b.addLogToRepo(s3Path, def.FullEnvironmentPath())

33 changes: 1 addition & 32 deletions build/builder_test.go
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@ import (
"os/exec"
"path/filepath"
"strings"
"sync/atomic"
"testing"
"time"

@@ -97,21 +96,6 @@ func TestBuilder(t *testing.T) {
builder, err := New(&conf, ms3, mwr)
So(err, ShouldBeNil)

var bcbCount atomic.Uint64

bcbWait := 0 * time.Millisecond

bcb := func() {
<-time.After(bcbWait)
bcbCount.Add(1)

if bcbWait > 0 {
slog.Error("bcb finished")
}
}

builder.SetPostBuildCallback(bcb)

def := getExampleDefinition()

Convey("You can generate a singularity .def", func() {
@@ -238,8 +222,6 @@ Stage: final
err := builder.Build(def)
So(err, ShouldBeNil)

So(bcbCount.Load(), ShouldEqual, 0)

So(ms3.Def, ShouldEqual, filepath.Join(def.getS3Path(), "singularity.def"))
So(ms3.Data, ShouldContainSubstring, "specs:\n - xxhash@0.8.1 arch=None-None-x86_64_v4\n"+
" - r-seurat@4 arch=None-None-x86_64_v4\n - py-anndata@3.14 arch=None-None-x86_64_v4\n view")
@@ -356,21 +338,16 @@ packages:

So(ms3.SoftpackYML, ShouldEqual, expectedSoftpackYaml)
So(ms3.Readme, ShouldContainSubstring, expectedReadmeContent)

So(bcbCount.Load(), ShouldEqual, 1)
})

Convey("Build returns an error if the upload fails", func() {
ms3.Fail = true
err := builder.Build(def)
So(err, ShouldNotBeNil)

So(bcbCount.Load(), ShouldEqual, 0)
})

Convey("Build logs an error if the run fails", func() {
mwr.Fail = true
bcbWait = 500 * time.Millisecond

err := builder.Build(def)
So(err, ShouldBeNil)
@@ -384,21 +361,15 @@ packages:
})
So(ok, ShouldBeTrue)

<-time.After(bcbWait)

logLines := strings.Split(logWriter.String(), "\n")
So(len(logLines), ShouldEqual, 3)
So(len(logLines), ShouldEqual, 2)

So(logLines[0], ShouldContainSubstring,
"msg=\"Async part of build failed\" err=\""+ErrBuildFailed+"\" s3Path=some_path/"+def.getS3Path())

So(logLines[1], ShouldContainSubstring, "finished")

data, ok := mc.GetFile(filepath.Join(def.getRepoPath(), core.BuilderOut))
So(ok, ShouldBeTrue)
So(data, ShouldContainSubstring, "output")

So(bcbCount.Load(), ShouldEqual, 1)
})

Convey("You can't run the same build simultaneously", func() {
@@ -477,8 +448,6 @@ packages:
expectedLog = "\"Async part of build failed\" err=\"an error\\n\""

So(logWriter.String(), ShouldContainSubstring, expectedLog)

So(bcbCount.Load(), ShouldEqual, 2)
})
})
}
5 changes: 0 additions & 5 deletions cmd/server.go
Original file line number Diff line number Diff line change
@@ -30,7 +30,6 @@ import (
"github.com/spf13/cobra"
"github.com/wtsi-hgi/go-softpack-builder/build"
"github.com/wtsi-hgi/go-softpack-builder/config"
"github.com/wtsi-hgi/go-softpack-builder/reindex"
"github.com/wtsi-hgi/go-softpack-builder/server"
)

@@ -143,10 +142,6 @@ past reindexHours, and only if a reindex is not still ongoing.
die("could not create a builder: %s", err)
}

r := reindex.New(conf)

b.SetPostBuildCallback(r.Reindex)

s := server.New(b, conf)
defer s.Stop()

12 changes: 3 additions & 9 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -49,11 +49,9 @@ type Config struct {
} `yaml:"module"`
CustomSpackRepo string `yaml:"customSpackRepo"`
Spack struct {
BuildImage string `yaml:"buildImage"`
FinalImage string `yaml:"finalImage"`
ProcessorTarget string `yaml:"processorTarget"`
ReindexHours float64 `yaml:"reindexHours"`
Path string `yaml:"path"`
BuildImage string `yaml:"buildImage"`
FinalImage string `yaml:"finalImage"`
ProcessorTarget string `yaml:"processorTarget"`
} `yaml:"spack"`
CoreURL string `yaml:"coreURL"`
ListenURL string `yaml:"listenURL"`
@@ -106,9 +104,5 @@ func Parse(r io.Reader) (*Config, error) {
}
}

if c.Spack.Path == "" {
c.Spack.Path = "spack"
}

return c, nil
}
2 changes: 0 additions & 2 deletions config/config_test.go
Original file line number Diff line number Diff line change
@@ -49,8 +49,6 @@ func TestConfig(t *testing.T) {
So(config.Spack.BuildImage, ShouldEqual, "spack/ubuntu-jammy:latest")
So(config.Spack.FinalImage, ShouldEqual, "ubuntu:22.04")
So(config.Spack.ProcessorTarget, ShouldEqual, "x86_64_v4")
So(config.Spack.ReindexHours, ShouldEqual, 24.0)
So(config.Spack.Path, ShouldEqual, "/usr/bin/spack")
So(config.CoreURL, ShouldEqual, "http://x.y.z:9837/softpack")
So(config.ListenURL, ShouldEqual, "localhost:2456")
})
106 changes: 0 additions & 106 deletions debounce/debounce.go

This file was deleted.

84 changes: 0 additions & 84 deletions debounce/debounce_test.go

This file was deleted.

2 changes: 0 additions & 2 deletions internal/tests/testdata/config.yml
Original file line number Diff line number Diff line change
@@ -16,8 +16,6 @@ spack:
buildImage: "spack/ubuntu-jammy:latest"
finalImage: "ubuntu:22.04"
processorTarget: "x86_64_v4"
reindexHours: 24
path: "/usr/bin/spack"

coreURL: "http://x.y.z:9837/softpack"
listenURL: "localhost:2456"
Loading