Skip to content

Commit

Permalink
one default value
Browse files Browse the repository at this point in the history
  • Loading branch information
ItamarYuran committed Oct 15, 2024
1 parent c76c458 commit 56bf6e1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
13 changes: 7 additions & 6 deletions cmd/lakectl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,9 @@ const (
parallelismFlagName = "parallelism"
noProgressBarFlagName = "no-progress"

defaultParallelismConfig = -1
defaultSyncParallelism = 25
defaultSyncPresign = true
defaultNoProgress = false
defaultParallelism = 25
defaultSyncPresign = true
defaultNoProgress = false

myRepoExample = "lakefs://my-repo"
myBucketExample = "s3://my-bucket"
Expand All @@ -182,7 +181,7 @@ func withRecursiveFlag(cmd *cobra.Command, usage string) {
}

func withParallelismFlag(cmd *cobra.Command) {
cmd.Flags().IntP(parallelismFlagName, "p", defaultSyncParallelism,
cmd.Flags().IntP(parallelismFlagName, "p", defaultParallelism,
"Max concurrent operations to perform")
}

Expand Down Expand Up @@ -249,9 +248,11 @@ func getSyncFlags(cmd *cobra.Command, client *apigen.ClientWithResponses) local.
if parallelism < 1 {
DieFmt("Invalid value for parallelism (%d), minimum is 1.\n", parallelism)
}
setParallelism := cmd.Flags().Changed(parallelismFlagName)

presignMode := getPresignMode(cmd, client)
return local.SyncFlags{
SetParallelism: setParallelism,
Parallelism: parallelism,
Presign: presignMode.Enabled,
PresignMultipart: presignMode.Multipart,
Expand Down Expand Up @@ -578,7 +579,7 @@ func initConfig() {
viper.SetDefault("server.retries.min_wait_interval", defaultMinRetryInterval)
viper.SetDefault("experimental.local.posix_permissions.enabled", false)
viper.SetDefault("local.skip_non_regular_files", false)
viper.SetDefault("options.parallelism", defaultParallelismConfig)
viper.SetDefault("options.parallelism", defaultParallelism)

cfgErr = viper.ReadInConfig()
}
1 change: 1 addition & 0 deletions pkg/local/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const (
)

type SyncFlags struct {
SetParallelism bool
Parallelism int
Presign bool
PresignMultipart bool
Expand Down
8 changes: 4 additions & 4 deletions pkg/local/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ func (s *SyncManager) Sync(rootPath string, remote *uri.URI, changeSet <-chan *C
defer s.progressBar.Stop()

wg, ctx := errgroup.WithContext(s.ctx)
parallelismToUse := s.cfg.Parallelism
if parallelismToUse <= 0 {
parallelismToUse = s.cfg.SyncFlags.Parallelism
parallelism := s.cfg.Parallelism
if s.cfg.SyncFlags.SetParallelism {
parallelism = s.cfg.SyncFlags.Parallelism
}
for i := 0; i < parallelismToUse; i++ {
for i := 0; i < parallelism; i++ {
wg.Go(func() error {
for change := range changeSet {
if err := s.apply(ctx, rootPath, remote, change); err != nil {
Expand Down

0 comments on commit 56bf6e1

Please sign in to comment.