Skip to content

Commit 7e6f63d

Browse files
committed
feat(cli): add --no-retry and --retry-max-time flags to push/pull/build/fetch
Signed-off-by: Zhao Chen <winters.zc@antgroup.com>
1 parent 7282930 commit 7e6f63d

8 files changed

Lines changed: 26 additions & 2 deletions

File tree

cmd/build.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ func init() {
6161
flags.BoolVar(&buildConfig.Raw, "raw", true, "turning on this flag will build model artifact layers in raw format")
6262
flags.BoolVar(&buildConfig.Reasoning, "reasoning", false, "turning on this flag will mark this model as reasoning model in the config")
6363
flags.BoolVar(&buildConfig.NoCreationTime, "no-creation-time", false, "turning on this flag will not set createdAt in the config, which will be helpful for repeated builds")
64+
flags.BoolVar(&buildConfig.RetryConfig.NoRetry, "no-retry", false, "Disable retry on transient errors")
65+
flags.DurationVar(&buildConfig.RetryConfig.MaxRetryTime, "retry-max-time", 0, "Max total retry time per file (0 = dynamic based on file size)")
6466

6567
if err := viper.BindPFlags(flags); err != nil {
6668
panic(fmt.Errorf("bind build flags to viper: %w", err))

cmd/fetch.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ func init() {
5555
flags.StringVar(&fetchConfig.Output, "output", "", "specify the directory for fetching the model artifact")
5656
flags.StringSliceVar(&fetchConfig.Patterns, "patterns", []string{}, "specify the patterns for fetching the model artifact")
5757
flags.StringVar(&fetchConfig.DragonflyEndpoint, "dragonfly-endpoint", "", "specify the dragonfly endpoint for the pull operation, which will download and hardlink the blob by dragonfly GRPC service.")
58+
flags.BoolVar(&fetchConfig.RetryConfig.NoRetry, "no-retry", false, "Disable retry on transient errors")
59+
flags.DurationVar(&fetchConfig.RetryConfig.MaxRetryTime, "retry-max-time", 0, "Max total retry time per file (0 = dynamic based on file size)")
5860

5961
if err := viper.BindPFlags(flags); err != nil {
6062
panic(fmt.Errorf("bind fetch flags to viper: %w", err))

cmd/pull.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ func init() {
5555
flags.StringVar(&pullConfig.ExtractDir, "extract-dir", "", "specify the extract dir for extracting the model artifact")
5656
flags.BoolVar(&pullConfig.ExtractFromRemote, "extract-from-remote", false, "turning on this flag will pull and extract the data from remote registry and no longer store model artifact locally, so user must specify extract-dir as the output directory")
5757
flags.StringVar(&pullConfig.DragonflyEndpoint, "dragonfly-endpoint", "", "specify the dragonfly endpoint for the pull operation, which will download and hardlink the blob by dragonfly GRPC service, this mode requires extract-from-remote must be true")
58+
flags.BoolVar(&pullConfig.RetryConfig.NoRetry, "no-retry", false, "Disable retry on transient errors")
59+
flags.DurationVar(&pullConfig.RetryConfig.MaxRetryTime, "retry-max-time", 0, "Max total retry time per file (0 = dynamic based on file size)")
5860

5961
if err := viper.BindPFlags(flags); err != nil {
6062
panic(fmt.Errorf("bind pull flags to viper: %w", err))

cmd/push.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ func init() {
5353
flags.BoolVar(&pushConfig.Insecure, "insecure", false, "turning on this flag will disable TLS verification")
5454
flags.BoolVar(&pushConfig.Nydusify, "nydusify", false, "[EXPERIMENTAL] nydusify the model artifact")
5555
flags.MarkHidden("nydusify")
56+
flags.BoolVar(&pushConfig.RetryConfig.NoRetry, "no-retry", false, "Disable retry on transient errors")
57+
flags.DurationVar(&pushConfig.RetryConfig.MaxRetryTime, "retry-max-time", 0, "Max total retry time per file (0 = dynamic based on file size)")
5658

5759
if err := viper.BindPFlags(flags); err != nil {
5860
panic(fmt.Errorf("bind push flags to viper: %w", err))

pkg/config/build.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616

1717
package config
1818

19-
import "fmt"
19+
import (
20+
"fmt"
21+
22+
"github.com/modelpack/modctl/pkg/retrypolicy"
23+
)
2024

2125
const (
2226
// defaultBuildConcurrency is the default number of concurrent builds.
@@ -36,6 +40,7 @@ type Build struct {
3640
Raw bool
3741
Reasoning bool
3842
NoCreationTime bool
43+
RetryConfig retrypolicy.Config
3944
}
4045

4146
func NewBuild() *Build {

pkg/config/fetch.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import (
2020
"fmt"
2121
"io"
2222
"os"
23+
24+
"github.com/modelpack/modctl/pkg/retrypolicy"
2325
)
2426

2527
const (
@@ -38,6 +40,7 @@ type Fetch struct {
3840
ProgressWriter io.Writer
3941
DisableProgress bool
4042
Hooks PullHooks
43+
RetryConfig retrypolicy.Config
4144
}
4245

4346
func NewFetch() *Fetch {

pkg/config/pull.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import (
2222
"os"
2323

2424
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
25+
26+
"github.com/modelpack/modctl/pkg/retrypolicy"
2527
)
2628

2729
const (
@@ -40,6 +42,7 @@ type Pull struct {
4042
ProgressWriter io.Writer
4143
DisableProgress bool
4244
DragonflyEndpoint string
45+
RetryConfig retrypolicy.Config
4346
}
4447

4548
func NewPull() *Pull {

pkg/config/push.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616

1717
package config
1818

19-
import "fmt"
19+
import (
20+
"fmt"
21+
22+
"github.com/modelpack/modctl/pkg/retrypolicy"
23+
)
2024

2125
const (
2226
// defaultPushConcurrency is the default number of concurrent push operations.
@@ -28,6 +32,7 @@ type Push struct {
2832
PlainHTTP bool
2933
Insecure bool
3034
Nydusify bool
35+
RetryConfig retrypolicy.Config
3136
}
3237

3338
func NewPush() *Push {

0 commit comments

Comments
 (0)