Skip to content
Open
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
1 change: 1 addition & 0 deletions config/ome-agent/ome-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ download_size_limit_gb: 650
enable_size_limit_check: true
hf_download_timeout: "72h"
hf_download_stale_progress_timeout: "30m"
artifact_upload_lock_timeout: "120h"

source:
storage_uri: "oci://n/<namespace>/b/<bucket-name>/o/<object-name>"
Expand Down
5 changes: 4 additions & 1 deletion internal/ome-agent/replica/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ type Config struct {
LocalPath string `mapstructure:"local_path" validate:"required"`
DownloadSizeLimitGB int `mapstructure:"download_size_limit_gb"`
EnableSizeLimitCheck bool `mapstructure:"enable_size_limit_check"`
NumConnections int `mapstructure:"num_connections"`
TargetArtifactReuseAllowed bool `mapstructure:"target_artifact_reuse_allowed"`
NumConnections int `mapstructure:"num_connections" validate:"gt=0"`
HFDownloadTimeout time.Duration `mapstructure:"hf_download_timeout"`
HFDownloadStaleProgressTimeout time.Duration `mapstructure:"hf_download_stale_progress_timeout"`
ArtifactUploadLockTimeout time.Duration `mapstructure:"artifact_upload_lock_timeout"`

Source struct {
StorageURIStr string `mapstructure:"storage_uri" validate:"required"`
Expand Down Expand Up @@ -67,6 +69,7 @@ func defaultConfig() *Config {
EnableSizeLimitCheck: true,
HFDownloadTimeout: 72 * time.Hour,
HFDownloadStaleProgressTimeout: 30 * time.Minute,
ArtifactUploadLockTimeout: 120 * time.Hour,
Comment thread
op109lvb marked this conversation as resolved.
}
}

Expand Down
22 changes: 22 additions & 0 deletions internal/ome-agent/replica/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ func TestWithViper(t *testing.T) {
v.Set("enable_size_limit_check", true)
v.Set("hf_download_timeout", "2h")
v.Set("hf_download_stale_progress_timeout", "15m")
v.Set("artifact_upload_lock_timeout", "3h")
v.Set("source.storage_uri", "oci://n/test-src-namespace/b/test-src-bucket/o/models")
v.Set("target.storage_uri", "oci://n/test-tgt-namespace/b/test-tgt-bucket/o/models")
return v
Expand All @@ -176,6 +177,7 @@ func TestWithViper(t *testing.T) {
assert.Equal(t, true, c.EnableSizeLimitCheck)
assert.Equal(t, 2*time.Hour, c.HFDownloadTimeout)
assert.Equal(t, 15*time.Minute, c.HFDownloadStaleProgressTimeout)
assert.Equal(t, 3*time.Hour, c.ArtifactUploadLockTimeout)
assert.Equal(t, "oci://n/test-src-namespace/b/test-src-bucket/o/models", c.Source.StorageURIStr)
assert.Equal(t, "oci://n/test-tgt-namespace/b/test-tgt-bucket/o/models", c.Target.StorageURIStr)
},
Expand All @@ -193,6 +195,7 @@ func TestWithViper(t *testing.T) {
assert.Equal(t, true, c.EnableSizeLimitCheck)
assert.Equal(t, 72*time.Hour, c.HFDownloadTimeout)
assert.Equal(t, 30*time.Minute, c.HFDownloadStaleProgressTimeout)
assert.Equal(t, 120*time.Hour, c.ArtifactUploadLockTimeout)
},
},
{
Expand Down Expand Up @@ -384,6 +387,24 @@ func TestConfig_Validate(t *testing.T) {
},
expectError: true,
},
{
name: "invalid NumConnections",
setupConfig: func() *Config {
return &Config{
LocalPath: "/test/path",
DownloadSizeLimitGB: 100,
EnableSizeLimitCheck: true,
NumConnections: 0,
Source: SourceStruct{
StorageURIStr: validSourceURI,
},
Target: TargetStruct{
StorageURIStr: validTargetURI,
},
}
},
expectError: true,
},
{
name: "invalid source storage URI",
setupConfig: func() *Config {
Expand Down Expand Up @@ -425,6 +446,7 @@ func TestDefaultConfig(t *testing.T) {
assert.Equal(t, 10, config.NumConnections)
assert.Equal(t, 650, config.DownloadSizeLimitGB)
assert.Equal(t, true, config.EnableSizeLimitCheck)
assert.Equal(t, 120*time.Hour, config.ArtifactUploadLockTimeout)
}

func TestConfig_ValidateRequiredDependencies(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions internal/ome-agent/replica/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ func TestModuleIntegration(t *testing.T) {
v.Set("num_connections", 5)
v.Set("download_size_limit_gb", 100)
v.Set("enable_size_limit_check", true)
v.Set("target_artifact_reuse_allowed", true)
v.Set("source.storage_uri", "oci://n/test-src-namespace/b/test-src-bucket/o/models")
v.Set("target.storage_uri", "oci://n/test-tgt-namespace/b/test-tgt-bucket/o/models")

Expand Down Expand Up @@ -235,6 +236,7 @@ func TestModuleIntegration(t *testing.T) {
require.NoError(t, err)
assert.NotNil(t, config)
assert.Equal(t, "/test/path", config.LocalPath)
assert.True(t, config.TargetArtifactReuseAllowed)
assert.Equal(t, "oci://n/test-src-namespace/b/test-src-bucket/o/models", config.Source.StorageURIStr)
assert.Equal(t, mockDataStores[0], config.Source.OCIOSDataStore)
assert.Equal(t, mockDataStores[1], config.Target.OCIOSDataStore)
Expand Down
Loading
Loading