Skip to content

Commit c93862b

Browse files
committed
Add --machines flag to allow control over the machine setup without requiring a configuration file
1 parent 1884613 commit c93862b

File tree

2 files changed

+49
-16
lines changed

2 files changed

+49
-16
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ trickest execute --workflow <workflow_or_tool_name> --space <space_name> --confi
128128
| --set-name | string | / | Sets the new workflow name and will copy the workflow to space and project supplied |
129129
| --ci | boolean | false | Enable CI mode (in-progress executions will be stopped when the CLI is forcefully stopped - if not set, you will be asked for confirmation) |
130130
| --create-project | boolean | false | If the project doesn't exist, create one using the project flag as its name (or workflow/tool name if project flag is not set) |
131+
| --machines | string | / | Specify the number of machines (format: small-medium-large). Examples: 1-1-1, 0-0-3 |
131132

132133
#### Provide parameters using **config.yaml** file
133134

cmd/execute/execute.go

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"math"
88
"os"
99
"path"
10+
"regexp"
1011
"sort"
1112
"strconv"
1213
"strings"
@@ -24,22 +25,23 @@ import (
2425
)
2526

2627
var (
27-
newWorkflowName string
28-
configFile string
29-
watch bool
30-
showParams bool
31-
executionMachines types.Machines
32-
fleet *types.Fleet
33-
nodesToDownload = make(map[string]output.NodeInfo, 0)
34-
allNodes map[string]*types.TreeNode
35-
roots []*types.TreeNode
36-
workflowYAML string
37-
maxMachines bool
38-
downloadAllNodes bool
39-
outputsDirectory string
40-
outputNodesFlag string
41-
ci bool
42-
createProject bool
28+
newWorkflowName string
29+
configFile string
30+
watch bool
31+
showParams bool
32+
executionMachines types.Machines
33+
fleet *types.Fleet
34+
nodesToDownload = make(map[string]output.NodeInfo, 0)
35+
allNodes map[string]*types.TreeNode
36+
roots []*types.TreeNode
37+
workflowYAML string
38+
maxMachines bool
39+
machineConfiguration string
40+
downloadAllNodes bool
41+
outputsDirectory string
42+
outputNodesFlag string
43+
ci bool
44+
createProject bool
4345
)
4446

4547
// ExecuteCmd represents the execute command
@@ -87,6 +89,35 @@ var ExecuteCmd = &cobra.Command{
8789
executionMachines = version.MaxMachines
8890
}
8991

92+
if machineConfiguration != "" {
93+
pattern := `^\d+-\d+-\d+$`
94+
regex := regexp.MustCompile(pattern)
95+
if regex.MatchString(machineConfiguration) {
96+
parts := strings.Split(machineConfiguration, "-")
97+
98+
machines := &types.Machines{}
99+
100+
if small, err := strconv.Atoi(parts[0]); err == nil && small != 0 {
101+
machines.Small = &small
102+
}
103+
104+
if medium, err := strconv.Atoi(parts[1]); err == nil && medium != 0 {
105+
machines.Medium = &medium
106+
}
107+
108+
if large, err := strconv.Atoi(parts[2]); err == nil && large != 0 {
109+
machines.Large = &large
110+
}
111+
112+
executionMachines = *machines
113+
114+
} else {
115+
fmt.Printf("Invalid machine configuration \"%s\".\n", machineConfiguration)
116+
fmt.Println("Please use the format: small-medium-large (e.g., 0-0-3)")
117+
os.Exit(0)
118+
}
119+
}
120+
90121
outputNodes := make([]string, 0)
91122
if outputNodesFlag != "" {
92123
outputNodes = strings.Split(outputNodesFlag, ",")
@@ -110,6 +141,7 @@ func init() {
110141
ExecuteCmd.Flags().BoolVar(&showParams, "show-params", false, "Show parameters in the workflow tree")
111142
// ExecuteCmd.Flags().StringVar(&workflowYAML, "file", "", "Workflow YAML file to execute")
112143
ExecuteCmd.Flags().BoolVar(&maxMachines, "max", false, "Use maximum number of machines for workflow execution")
144+
ExecuteCmd.Flags().StringVar(&machineConfiguration, "machines", "", "Specify the number of machines (format: small-medium-large). Examples: 1-1-1, 0-0-3")
113145
ExecuteCmd.Flags().BoolVar(&downloadAllNodes, "output-all", false, "Download all outputs when the execution is finished")
114146
ExecuteCmd.Flags().StringVar(&outputNodesFlag, "output", "", "A comma separated list of nodes which outputs should be downloaded when the execution is finished")
115147
ExecuteCmd.Flags().StringVar(&outputsDirectory, "output-dir", "", "Path to directory which should be used to store outputs")

0 commit comments

Comments
 (0)