Skip to content

Commit

Permalink
Added Parallelism configuration option to lakectl (#8283)
Browse files Browse the repository at this point in the history
  • Loading branch information
ItamarYuran authored Oct 23, 2024
1 parent d57ca0d commit 2f4a142
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions cmd/lakectl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ type Configuration struct {
EndpointURL lakefsconfig.OnlyString `mapstructure:"endpoint_url"`
Retries RetriesCfg `mapstructure:"retries"`
} `mapstructure:"server"`
Options struct {
Parallelism int `mapstructure:"parallelism"`
} `mapstructure:"options"`
Metastore struct {
Type lakefsconfig.OnlyString `mapstructure:"type"`
Hive struct {
Expand Down Expand Up @@ -153,9 +156,9 @@ const (
parallelismFlagName = "parallelism"
noProgressBarFlagName = "no-progress"

defaultSyncParallelism = 25
defaultSyncPresign = true
defaultNoProgress = false
defaultParallelism = 25
defaultSyncPresign = true
defaultNoProgress = false

myRepoExample = "lakefs://my-repo"
myBucketExample = "s3://my-bucket"
Expand All @@ -178,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 @@ -245,6 +248,10 @@ func getSyncFlags(cmd *cobra.Command, client *apigen.ClientWithResponses) local.
if parallelism < 1 {
DieFmt("Invalid value for parallelism (%d), minimum is 1.\n", parallelism)
}
changed := cmd.Flags().Changed(parallelismFlagName)
if viper.IsSet("options.parallelism") && !changed {
parallelism = cfg.Options.Parallelism
}

presignMode := getPresignMode(cmd, client)
return local.SyncFlags{
Expand Down Expand Up @@ -574,6 +581,5 @@ 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)

cfgErr = viper.ReadInConfig()
}

0 comments on commit 2f4a142

Please sign in to comment.