Skip to content
Draft
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions cmd/model-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ type config struct {
numDownloadWorker int
namespace string
logLevel string
downloadTimeout time.Duration
}

// Logger type alias for zap.SugaredLogger
Expand Down Expand Up @@ -73,6 +74,7 @@ func init() {
rootCmd.PersistentFlags().IntVar(&cfg.numDownloadWorker, "num-download-worker", 5, "Number of download workers")
rootCmd.PersistentFlags().StringVar(&cfg.namespace, "namespace", "ome", "Kubernetes namespace to use")
rootCmd.PersistentFlags().StringVar(&cfg.logLevel, "log-level", "info", "Log level (debug, info, warn, error)")
rootCmd.PersistentFlags().DurationVar(&cfg.downloadTimeout, "download-timeout", 6*time.Hour, "Maximum time allowed for a single model download before it is cancelled")

_ = v.BindPFlags(rootCmd.PersistentFlags())
v.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
Expand Down Expand Up @@ -268,6 +270,9 @@ func initializeComponents(
logger,
baseModelInformer.Lister(),
clusterBaseModelInformer.Lister(),
cfg.nodeName,
cfg.namespace,
cfg.downloadTimeout,
)
if err != nil {
return nil, nil, fmt.Errorf("failed to create gopher: %w", err)
Expand Down
3 changes: 3 additions & 0 deletions cmd/model-agent/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"net/http/httptest"
"os"
"testing"
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -113,6 +114,7 @@ func TestDefaultConfig(t *testing.T) {
testCmd.Flags().StringVar(&cfg.downloadAuthType, "download-auth-type", "instance-principal", "authentication method for model download")
testCmd.Flags().IntVar(&cfg.numDownloadWorker, "num-download-worker", 3, "number of download workers")
testCmd.Flags().StringVar(&cfg.namespace, "namespace", "ome", "the namespace of the ome model agents daemon set")
testCmd.Flags().DurationVar(&cfg.downloadTimeout, "download-timeout", 6*time.Hour, "maximum time for a single model download")

// Call initConfig to set cfg.nodeName
initConfig(nil, nil)
Expand All @@ -127,6 +129,7 @@ func TestDefaultConfig(t *testing.T) {
assert.Equal(t, "instance-principal", cfg.downloadAuthType)
assert.Equal(t, 3, cfg.numDownloadWorker)
assert.Equal(t, "ome", cfg.namespace)
assert.Equal(t, 6*time.Hour, cfg.downloadTimeout)
}

func TestInitializeLogger(t *testing.T) {
Expand Down
Loading
Loading