Skip to content

Commit

Permalink
add option to not dynamically load managed containers
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-astra-video committed May 6, 2024
1 parent 0ae06e2 commit adcfed1
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,24 @@ func (sb EnvValue) String() string {
type OptimizationFlags map[string]EnvValue

type Worker struct {
manager *DockerManager
manager *DockerManager
noManagedContainers bool

externalContainers map[string]*RunnerContainer
mu *sync.Mutex
}

func NewWorker(containerImageID string, gpus []string, modelDir string) (*Worker, error) {
func NewWorker(containerImageID string, gpus []string, modelDir string, noManagedContainers bool) (*Worker, error) {
manager, err := NewDockerManager(containerImageID, gpus, modelDir)
if err != nil {
return nil, err
}

return &Worker{
manager: manager,
externalContainers: make(map[string]*RunnerContainer),
mu: &sync.Mutex{},
manager: manager,
noManagedContainers: noManagedContainers,
externalContainers: make(map[string]*RunnerContainer),
mu: &sync.Mutex{},
}, nil
}

Expand Down Expand Up @@ -276,6 +278,10 @@ func (w *Worker) borrowContainer(ctx context.Context, pipeline, modelID string)

w.mu.Unlock()

if w.noManagedContainers {
return nil, errors.New("no runners available")
}

return w.manager.Borrow(ctx, pipeline, modelID)
}

Expand Down

0 comments on commit adcfed1

Please sign in to comment.