Skip to content

Commit f88f814

Browse files
committed
Undo cmd folder restructuring
1 parent 96619b8 commit f88f814

File tree

12 files changed

+202
-164
lines changed

12 files changed

+202
-164
lines changed

cmd/cmp.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//go:build experimental
2+
3+
package cmd
4+
5+
import (
6+
"github.com/spf13/cobra"
7+
"pbench/cmd/cmp"
8+
)
9+
10+
var cmpCmd = &cobra.Command{
11+
Use: `cmp [flags] [directory 1] [directory 2]`,
12+
DisableFlagsInUseLine: true,
13+
Run: cmp.Run,
14+
Args: cobra.ExactArgs(2),
15+
Short: "Compare two query result directories",
16+
}
17+
18+
func init() {
19+
RootCmd.AddCommand(cmpCmd)
20+
cmpCmd.Flags().StringVarP(&cmp.FileIdRegexStr, "file-id-regex", "r", `.*(query_\d{2}).*\.output`, "regex to extract file id from file names in two directories to find matching files to compare")
21+
cmpCmd.Flags().StringVarP(&cmp.OutputPath, "output-path", "o", "./diff", "diff output path")
22+
}

cmd/cmp/cmp.go

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
package genconfig
1+
package cmd
22

33
import (
44
"github.com/spf13/cobra"
5-
"pbench/cmd"
5+
"pbench/cmd/genconfig"
66
)
77

88
var genConfigCmd = &cobra.Command{
99
Use: `genconfig [flags] [directory to search recursively for config.json]`,
1010
DisableFlagsInUseLine: true,
11-
Run: Run,
11+
Run: genconfig.Run,
1212
Args: cobra.ExactArgs(1),
1313
Short: "Generate benchmark cluster configurations",
1414
}
1515

1616
func init() {
17-
cmd.RootCmd.AddCommand(genConfigCmd)
18-
genConfigCmd.Flags().StringVarP(&TemplatePath, "template-dir",
17+
RootCmd.AddCommand(genConfigCmd)
18+
genConfigCmd.Flags().StringVarP(&genconfig.TemplatePath, "template-dir",
1919
"t", "", "Specifies the template directory. Use built-in template if not specified.")
20-
genConfigCmd.Flags().StringVarP(&ParameterPath, "parameter-file",
20+
genConfigCmd.Flags().StringVarP(&genconfig.ParameterPath, "parameter-file",
2121
"p", "", "Specifies the parameter file. Use built-in defaults if not specified.")
2222
genConfigCmd.AddCommand(&cobra.Command{
2323
Use: "default",
2424
Short: "Print the built-in default generator parameter file.",
2525
DisableFlagsInUseLine: true,
26-
Run: PrintDefaultParams,
26+
Run: genconfig.PrintDefaultParams,
2727
})
2828
}

cmd/loadjson.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"github.com/spf13/cobra"
6+
"os"
7+
"pbench/cmd/loadjson"
8+
"pbench/utils"
9+
"runtime"
10+
"time"
11+
)
12+
13+
// loadJsonCmd represents the loadjson command
14+
var loadJsonCmd = &cobra.Command{
15+
Use: `loadjson [flags] [list of files or directories to process]`,
16+
Short: "Load query JSON files into event listener database and run recorders",
17+
Long: `Load query JSON files into event listener database and run recorders`,
18+
DisableFlagsInUseLine: true,
19+
Args: func(cmd *cobra.Command, args []string) error {
20+
if len(args) < 1 {
21+
return fmt.Errorf("requires at least 1 arg, only received %d", len(args))
22+
}
23+
if loadjson.Parallelism < 1 || loadjson.Parallelism > runtime.NumCPU() {
24+
return fmt.Errorf("invalid parallelism: %d, it should be >= 1 and <= %d", loadjson.Parallelism, runtime.NumCPU())
25+
}
26+
utils.ExpandHomeDirectory(&loadjson.OutputPath)
27+
return nil
28+
},
29+
Run: loadjson.Run,
30+
}
31+
32+
func init() {
33+
RootCmd.AddCommand(loadJsonCmd)
34+
wd, _ := os.Getwd()
35+
loadJsonCmd.Flags().StringVarP(&loadjson.RunName, "name", "n", fmt.Sprintf("load_%s", time.Now().Format(utils.DirectoryNameTimeFormat)), `Assign a name to this run. (default: "load_<current time>")`)
36+
loadJsonCmd.Flags().StringVarP(&loadjson.Comment, "comment", "c", "", `Add a comment to this run (optional)`)
37+
loadJsonCmd.Flags().BoolVarP(&loadjson.RecordRun, "record-run", "r", false, "Record all the loaded JSON as a run")
38+
loadJsonCmd.Flags().StringVarP(&loadjson.OutputPath, "output-path", "o", wd, "Output directory path")
39+
loadJsonCmd.Flags().BoolVarP(&loadjson.ExtractPlanJson, "extract-plan", "x", false, "Extract the plan JSON from query JSON then save them to the output path")
40+
loadJsonCmd.Flags().IntVarP(&loadjson.Parallelism, "parallel", "P", runtime.NumCPU(), "Number of parallel threads to load json files")
41+
loadJsonCmd.Flags().StringVar(&loadjson.InfluxCfgPath, "influx", "", "InfluxDB connection config for run recorder (optional)")
42+
loadJsonCmd.Flags().StringVar(&loadjson.MySQLCfgPath, "mysql", "", "MySQL connection config for event listener and run recorder (optional)")
43+
}

cmd/loadjson/loadjson.go

Lines changed: 0 additions & 43 deletions
This file was deleted.

cmd/replay/replay.go renamed to cmd/replay.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package replay
1+
package cmd
22

33
import (
44
"fmt"
55
"github.com/spf13/cobra"
66
"os"
7-
"pbench/cmd"
7+
"pbench/cmd/replay"
88
"pbench/utils"
99
"time"
1010
)
@@ -22,17 +22,17 @@ We also expect the queries in this CSV file are sorted by "create_time" in ascen
2222
if len(args) != 1 {
2323
return fmt.Errorf("requires 1 arg, only received %d", len(args))
2424
}
25-
utils.ExpandHomeDirectory(&OutputPath)
25+
utils.ExpandHomeDirectory(&replay.OutputPath)
2626
utils.ExpandHomeDirectory(&args[0])
2727
return nil
2828
},
29-
Run: Run,
29+
Run: replay.Run,
3030
}
3131

3232
func init() {
33-
cmd.RootCmd.AddCommand(replayCmd)
33+
RootCmd.AddCommand(replayCmd)
3434
wd, _ := os.Getwd()
35-
PrestoFlags.InstallPrestoFlags(replayCmd)
36-
replayCmd.Flags().StringVarP(&OutputPath, "output-path", "o", wd, "Output directory path")
37-
replayCmd.Flags().StringVarP(&RunName, "name", "n", fmt.Sprintf("replay_%s", time.Now().Format(utils.DirectoryNameTimeFormat)), `Assign a name to this run. (default: "replay_<current time>")`)
35+
replay.PrestoFlags.Install(replayCmd)
36+
replayCmd.Flags().StringVarP(&replay.OutputPath, "output-path", "o", wd, "Output directory path")
37+
replayCmd.Flags().StringVarP(&replay.RunName, "name", "n", fmt.Sprintf("replay_%s", time.Now().Format(utils.DirectoryNameTimeFormat)), `Assign a name to this run. (default: "replay_<current time>")`)
3838
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//go:build experimental
22

3-
package round
3+
package cmd
44

55
import (
66
"github.com/spf13/cobra"
7-
"pbench/cmd"
7+
"pbench/cmd/round"
88
)
99

1010
// roundCmd represents the round command
@@ -16,19 +16,19 @@ After processing the first row, it will only look at the matched columns. So if
1616
A PR was opened to fix the native/Java decimal precision discrepancy but so far it does not work quite well:
1717
https://github.com/facebookincubator/velox/pull/7944`,
1818
DisableFlagsInUseLine: true,
19-
Args: Args,
20-
Run: Run,
19+
Args: round.Args,
20+
Run: round.Run,
2121
}
2222

2323
func init() {
24-
cmd.RootCmd.AddCommand(roundCmd)
25-
roundCmd.Flags().IntVarP(&DecimalPrecision, "precision", "p", 12, "Decimal precision to preserve.")
26-
roundCmd.Flags().StringArrayVarP(&FileExtensions, "file-extension", "e", []string{".output"},
24+
RootCmd.AddCommand(roundCmd)
25+
roundCmd.Flags().IntVarP(&round.DecimalPrecision, "precision", "p", 12, "Decimal precision to preserve.")
26+
roundCmd.Flags().StringArrayVarP(&round.FileExtensions, "file-extension", "e", []string{".output"},
2727
"Specifies the file extensions ton include for processing (including the dot). You can specify multiple file extensions.")
28-
roundCmd.Flags().StringVarP(&FileFormat, "format", "f", "json",
28+
roundCmd.Flags().StringVarP(&round.FileFormat, "format", "f", "json",
2929
`Specifies the format of the files. Accepted values are: "csv"" or "json" which is the output file from the "run"" command`)
30-
roundCmd.Flags().BoolVarP(&InPlaceRewrite, "rewrite-in-place", "i", false,
30+
roundCmd.Flags().BoolVarP(&round.InPlaceRewrite, "rewrite-in-place", "i", false,
3131
"When turned on, we will rewrite the file in-place. Otherwise, we save the rewritten file separately.")
32-
roundCmd.Flags().BoolVarP(&Recursive, "recursive", "r", false,
32+
roundCmd.Flags().BoolVarP(&round.Recursive, "recursive", "r", false,
3333
`Recursively walk a path if a directory is provided in the arguments.`)
3434
}

cmd/run.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package cmd
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
"os"
6+
"pbench/cmd/run"
7+
"time"
8+
)
9+
10+
// runCmd represents the run command
11+
var runCmd = &cobra.Command{
12+
Use: `run [flags] [list of root-level benchmark stage JSON files]`,
13+
Short: "Run a benchmark",
14+
Long: `Run a benchmark that is defined by a sequence of JSON configuration files.`,
15+
DisableFlagsInUseLine: true,
16+
Args: cobra.MinimumNArgs(1),
17+
Run: run.Run,
18+
}
19+
20+
func init() {
21+
RootCmd.AddCommand(runCmd)
22+
runCmd.Flags().StringVarP(&run.Name, "name", "n", "", `Assign a name to this run. (default: "<main stage name>-<current time>")`)
23+
runCmd.Flags().StringVarP(&run.Comment, "comment", "c", "", `Add a comment to this run (optional)`)
24+
run.PrestoFlags.Install(runCmd)
25+
wd, _ := os.Getwd()
26+
runCmd.Flags().StringVarP(&run.OutputPath, "output-path", "o", wd, "Output directory path")
27+
runCmd.Flags().Int64VarP(&run.RandSeed, "seed", "e", time.Now().UnixMicro(), "Random seed for randomized execution")
28+
runCmd.Flags().IntVarP(&run.RandSkip, "rand-skip", "k", 0, "Skip the first N random selections from the sequence (optional)")
29+
runCmd.Flags().StringVar(&run.InfluxCfgPath, "influx", "", "InfluxDB connection config for run recorder (optional)")
30+
runCmd.Flags().StringVar(&run.MySQLCfgPath, "mysql", "", "MySQL connection config for run recorder (optional)")
31+
runCmd.Flags().StringVar(&run.PulumiCfgPath, "pulumi", "", "(only works when a MySQL run recorder is specified) Pulumi API config for storing deployment details with MySQL (optional)")
32+
}

cmd/run/run.go

Lines changed: 0 additions & 32 deletions
This file was deleted.

cmd/save.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
"github.com/spf13/cobra"
6+
"os"
7+
"pbench/cmd/save"
8+
"pbench/utils"
9+
"runtime"
10+
)
11+
12+
// saveCmd represents the save command
13+
var saveCmd = &cobra.Command{
14+
Use: `save [flags] [list of table names]`,
15+
Short: "Save table information for recreating the schema and data",
16+
Long: `Save table information for recreating the schema and data`,
17+
DisableFlagsInUseLine: true,
18+
Args: func(cmd *cobra.Command, args []string) error {
19+
utils.ExpandHomeDirectory(&save.OutputPath)
20+
if save.InputFilePath != "" {
21+
utils.ExpandHomeDirectory(&save.InputFilePath)
22+
} else if len(args) < 1 {
23+
return fmt.Errorf("requires at least 1 arg when -f is not used")
24+
}
25+
return nil
26+
},
27+
Run: save.Run,
28+
}
29+
30+
func init() {
31+
RootCmd.AddCommand(saveCmd)
32+
save.PrestoFlags.Install(saveCmd)
33+
wd, _ := os.Getwd()
34+
saveCmd.Flags().StringVarP(&save.OutputPath, "output-path", "o", wd, "Output directory path")
35+
saveCmd.Flags().StringVarP(&save.Catalog, "catalog", "", "", "Catalog name")
36+
saveCmd.Flags().StringVarP(&save.Schema, "schema", "", "", "Schema name")
37+
saveCmd.Flags().StringArrayVarP(&save.Session, "session", "", nil,
38+
"Session property (property can be used multiple times; format is\nkey=value; use 'SHOW SESSION' in Presto CLI to see available properties)")
39+
saveCmd.Flags().StringVarP(&save.InputFilePath, "file", "f", "", "CSV file to read catalog,schema,table.")
40+
saveCmd.Flags().IntVarP(&save.Parallelism, "parallel", "P", runtime.NumCPU(), "Number of parallel threads to save table summaries.")
41+
}

0 commit comments

Comments
 (0)