Skip to content

Commit

Permalink
feat: deprecate aiRunnerImage flag in favor of `aiRunnerImageOverri…
Browse files Browse the repository at this point in the history
…des`

This commit introduces deprecation logic for the `aiRunnerImage` flag, replacing
it with a new `aiRunnerImageOverrides` flag. The new flag is designed to support
enhanced image override functionality as implemented in the worker logic
in [ai-worker PR livepeer#293](livepeer/ai-worker#293).
  • Loading branch information
rickstaa committed Jan 23, 2025
1 parent 3089299 commit 6da604c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/livepeer/livepeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func parseLivepeerConfig() starter.LivepeerConfig {
cfg.AIWorker = flag.Bool("aiWorker", *cfg.AIWorker, "Set to true to run an AI worker")
cfg.AIModels = flag.String("aiModels", *cfg.AIModels, "Set models (pipeline:model_id) for AI worker to load upon initialization")
cfg.AIModelsDir = flag.String("aiModelsDir", *cfg.AIModelsDir, "Set directory where AI model weights are stored")
cfg.AIRunnerImage = flag.String("aiRunnerImage", *cfg.AIRunnerImage, `Set the docker image for the AI runner: Example - livepeer/ai-runner:0.0.1 . You can also provide a JSON string to map specific pipeline names to custom images, allowing for pipeline-specific image overrides: Example - '{"segment-anything-2": "livepeer/ai-runner:segment-anything-2-v1.0", "another-pipeline": "livepeer/ai-runner:another-pipeline-v2.0"}'`)

cfg.AIRunnerImage = flag.String("aiRunnerImage", *cfg.AIRunnerImage, "[Deprecated] Specify the base Docker image for the AI runner. Example: livepeer/ai-runner:0.0.1. Use -aiRunnerImageOverrides instead.")
cfg.AIRunnerImageOverrides = flag.String("aiRunnerImageOverrides", *cfg.AIRunnerImageOverrides, `Specify overrides for the Docker images used by the AI runner. Example: '{"segment-anything-2": "livepeer/ai-runner:segment-anything-2-v1.0", "another-pipeline": "livepeer/ai-runner:another-pipeline-v1.0"}'`)
// Live AI:
cfg.MediaMTXApiPassword = flag.String("mediaMTXApiPassword", "", "HTTP basic auth password for MediaMTX API requests")
cfg.LiveAITrickleHostForRunner = flag.String("liveAITrickleHostForRunner", "", "Trickle Host used by AI Runner; It's used to overwrite the publicly available Trickle Host")
Expand Down
36 changes: 27 additions & 9 deletions cmd/livepeer/starter/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ type LivepeerConfig struct {
OrchMinLivepeerVersion *string
TestOrchAvail *bool
AIRunnerImage *string
AIRunnerImageOverrides *string
KafkaBootstrapServers *string
KafkaUsername *string
KafkaPassword *string
Expand Down Expand Up @@ -214,6 +215,7 @@ func DefaultLivepeerConfig() LivepeerConfig {
defaultAIModels := ""
defaultAIModelsDir := ""
defaultAIRunnerImage := "livepeer/ai-runner:latest"
defaultAIRunnerImageOverrides := ""
defaultLiveAIAuthWebhookURL := ""
defaultLivePaymentInterval := 5 * time.Second
defaultGatewayHost := ""
Expand Down Expand Up @@ -318,14 +320,15 @@ func DefaultLivepeerConfig() LivepeerConfig {
TestTranscoder: &defaultTestTranscoder,

// AI:
AIServiceRegistry: &defaultAIServiceRegistry,
AIWorker: &defaultAIWorker,
AIModels: &defaultAIModels,
AIModelsDir: &defaultAIModelsDir,
AIRunnerImage: &defaultAIRunnerImage,
LiveAIAuthWebhookURL: &defaultLiveAIAuthWebhookURL,
LivePaymentInterval: &defaultLivePaymentInterval,
GatewayHost: &defaultGatewayHost,
AIServiceRegistry: &defaultAIServiceRegistry,
AIWorker: &defaultAIWorker,
AIModels: &defaultAIModels,
AIModelsDir: &defaultAIModelsDir,
AIRunnerImage: &defaultAIRunnerImage,
AIRunnerImageOverrides: &defaultAIRunnerImageOverrides,
LiveAIAuthWebhookURL: &defaultLiveAIAuthWebhookURL,
LivePaymentInterval: &defaultLivePaymentInterval,
GatewayHost: &defaultGatewayHost,

// Onchain:
EthAcctAddr: &defaultEthAcctAddr,
Expand Down Expand Up @@ -1211,7 +1214,22 @@ func StartLivepeer(ctx context.Context, cfg LivepeerConfig) {
return
}

n.AIWorker, err = worker.NewWorker(*cfg.AIRunnerImage, gpus, modelsDir)
// Retrieve image overrides from the config.
var imageOverrides worker.ImageOverrides
if err := json.Unmarshal([]byte(*cfg.AIRunnerImageOverrides), &imageOverrides); err != nil {
glog.Errorf("Error unmarshaling image overrides: %v", err)
return
}

// Backwards compatibility for deprecated flags.
if *cfg.AIRunnerImage != "" {
glog.Warning("-aiRunnerImage flag is deprecated and will be removed in a future release. Please use -aiWorkerImageOverrides instead")
if imageOverrides.Default == "" {
imageOverrides.Default = *cfg.AIRunnerImage
}
}

n.AIWorker, err = worker.NewWorker(imageOverrides, gpus, modelsDir)
if err != nil {
glog.Errorf("Error starting AI worker: %v", err)
return
Expand Down

0 comments on commit 6da604c

Please sign in to comment.