Skip to content

Commit b32b06e

Browse files
committed
Use parallelism and machines integers instead of machines struct in run and schedule info structs
1 parent ce2ff2b commit b32b06e

File tree

6 files changed

+24
-17
lines changed

6 files changed

+24
-17
lines changed

cmd/execute/helpers.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,16 @@ func getScripts(pageSize int, search string, name string) []types.Script {
9898
}
9999

100100
func createRun(versionID, fleetID uuid.UUID, watch bool, outputNodes []string, outputsDir string, useStaticIPs bool) {
101+
parallelism := 0
102+
if executionMachines.Default != nil {
103+
parallelism = *executionMachines.Default
104+
} else if executionMachines.SelfHosted != nil {
105+
parallelism = *executionMachines.SelfHosted
106+
}
107+
101108
run := types.CreateRun{
102109
VersionID: versionID,
103-
Machines: executionMachines,
110+
Parallelism: parallelism,
104111
Fleet: &fleetID,
105112
UseStaticIPs: useStaticIPs,
106113
}
@@ -135,12 +142,12 @@ func createRun(versionID, fleetID uuid.UUID, watch bool, outputNodes []string, o
135142
watch = true
136143
}
137144
if watch {
138-
WatchRun(createRunResp.ID, outputsDir, nodesToDownload, nil, false, &executionMachines, showParams)
145+
WatchRun(createRunResp.ID, outputsDir, nodesToDownload, nil, false, showParams)
139146
} else {
140147
availableMachines := GetAvailableMachines(fleetName)
141148
fmt.Println("Run successfully created! ID: " + createRunResp.ID.String())
142-
fmt.Print("Machines:\n" + FormatMachines(executionMachines, false))
143-
fmt.Print("\nAvailable:\n" + FormatMachines(availableMachines, false))
149+
fmt.Print("Machines:\n" + FormatMachines(executionMachines, true))
150+
fmt.Println("\nAvailable:\n" + FormatMachines(availableMachines, true))
144151
}
145152
}
146153

@@ -154,7 +161,6 @@ func createNewVersion(version *types.WorkflowVersionDetailed) *types.WorkflowVer
154161
Description: version.Description,
155162
WorkflowInfo: version.WorkflowInfo,
156163
Snapshot: false,
157-
MaxMachines: version.MaxMachines,
158164
}
159165

160166
data, err := json.Marshal(strippedVersion)

cmd/execute/watch.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/xlab/treeprint"
2323
)
2424

25-
func WatchRun(runID uuid.UUID, downloadPath string, nodesToDownload []string, filesToDownload []string, timestampOnly bool, machines *types.Machines, showParameters bool) {
25+
func WatchRun(runID uuid.UUID, downloadPath string, nodesToDownload []string, filesToDownload []string, timestampOnly bool, showParameters bool) {
2626
const fmtStr = "%-12s %v\n"
2727
writer := uilive.New()
2828
writer.Start()
@@ -73,7 +73,8 @@ func WatchRun(runID uuid.UUID, downloadPath string, nodesToDownload []string, fi
7373
out := ""
7474
out += fmt.Sprintf(fmtStr, "Name:", run.WorkflowName)
7575
out += fmt.Sprintf(fmtStr, "Status:", strings.ToLower(run.Status))
76-
out += fmt.Sprintf(fmtStr, "Machines:", FormatMachines(*machines, true))
76+
out += fmt.Sprintf(fmtStr, "Machines:", run.Machines)
77+
out += fmt.Sprintf(fmtStr, "Parallelism:", run.Parallelism)
7778
out += fmt.Sprintf(fmtStr, "Created:", run.CreatedDate.In(time.Local).Format(time.RFC1123)+
7879
" ("+util.FormatDuration(time.Since(run.CreatedDate))+" ago)")
7980
if run.Status != "PENDING" {

cmd/get/get.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ var GetCmd = &cobra.Command{
7878
output := string(data)
7979
fmt.Println(output)
8080
} else {
81-
execute.WatchRun(*run.ID, "", []string{}, []string{}, !watch, &runs[0].Machines, showNodeParams)
81+
execute.WatchRun(*run.ID, "", nil, nil, !watch, showNodeParams)
8282
}
8383
return
8484
} else {

types/download.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ type WorkflowVersionStripped struct {
6060
WorkflowInfo uuid.UUID `json:"workflow_info"`
6161
Name *string `json:"name,omitempty"`
6262
Description string `json:"description"`
63-
MaxMachines Machines `json:"max_machines"`
6463
Snapshot bool `json:"snapshot"`
6564
Data WorkflowVersionData `json:"data"`
6665
}

types/execute.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,19 @@ type TreeNode struct {
4242
}
4343

4444
type CreateRun struct {
45-
Machines Machines `json:"machines"`
45+
Parallelism int `json:"parallelism"`
4646
VersionID uuid.UUID `json:"workflow_version_info"`
4747
Vault uuid.UUID `json:"vault"`
4848
Fleet *uuid.UUID `json:"fleet,omitempty"`
4949
UseStaticIPs bool `json:"use_static_ips"`
5050
}
5151

5252
type CreateRunResponse struct {
53-
ID uuid.UUID `json:"id"`
54-
Name string `json:"name"`
55-
Machines Machines `json:"machines"`
56-
VersionID uuid.UUID `json:"workflow_version_info"`
57-
HiveInfo uuid.UUID `json:"hive_info"`
53+
ID uuid.UUID `json:"id"`
54+
Name string `json:"name"`
55+
Parallelism int `json:"parallelism"`
56+
VersionID uuid.UUID `json:"workflow_version_info"`
57+
HiveInfo uuid.UUID `json:"hive_info"`
5858
}
5959

6060
type WorkflowYAML struct {

types/list.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ type ScheduleInfo struct {
126126
Date *time.Time `json:"date,omitempty"`
127127
Workflow string `json:"workflow,omitempty"`
128128
RepeatPeriod int `json:"repeat_period,omitempty"`
129-
Machines *Machines `json:"machines,omitempty"`
129+
Parallelism int `json:"parallelism"`
130130
}
131131

132132
type Parameter struct {
@@ -152,7 +152,8 @@ type Run struct {
152152
ID *uuid.UUID `json:"id,omitempty"`
153153
Name string `json:"name,omitempty"`
154154
Status string `json:"status,omitempty"`
155-
Machines Machines `json:"machines,omitempty"`
155+
Machines int `json:"machines,omitempty"`
156+
Parallelism int `json:"parallelism,omitempty"`
156157
WorkflowVersionInfo *uuid.UUID `json:"workflow_version_info,omitempty"`
157158
WorkflowInfo *uuid.UUID `json:"workflow_info,omitempty"`
158159
WorkflowName string `json:"workflow_name,omitempty"`

0 commit comments

Comments
 (0)