Skip to content

Commit b6b9b93

Browse files
authored
Sort based on the Task Key specified in the 'Depends On' field (#3000)
* add sort task dependency by key * add task depend on into test code * refactor task depends on sort logic
1 parent 9f37c2d commit b6b9b93

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

jobs/resource_job.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ func (js *JobSettings) sortTasksByKey() {
291291
func (js *JobSettings) adjustTasks() {
292292
js.sortTasksByKey()
293293
for _, task := range js.Tasks {
294+
sort.Slice(task.DependsOn, func(i, j int) bool {
295+
return task.DependsOn[i].TaskKey < task.DependsOn[j].TaskKey
296+
})
294297
sortWebhookNotifications(task.WebhookNotifications)
295298
}
296299
}

jobs/resource_job_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,11 @@ func TestResourceJobCreate_JobClusters(t *testing.T) {
459459
NodeTypeID: "b",
460460
NumWorkers: 3,
461461
},
462+
DependsOn: []jobs.TaskDependency{
463+
{
464+
TaskKey: "a",
465+
},
466+
},
462467
NotebookTask: &NotebookTask{
463468
NotebookPath: "/Stuff",
464469
},
@@ -537,6 +542,10 @@ func TestResourceJobCreate_JobClusters(t *testing.T) {
537542
task {
538543
task_key = "b"
539544
545+
depends_on {
546+
task_key = "a"
547+
}
548+
540549
new_cluster {
541550
spark_version = "a"
542551
node_type_id = "b"

0 commit comments

Comments
 (0)