Skip to content

Commit

Permalink
Sort based on the Task Key specified in the 'Depends On' field (#3000)
Browse files Browse the repository at this point in the history
* add sort task dependency by key

* add task depend on into test code

* refactor task depends on sort logic
  • Loading branch information
case-k-git authored Jan 8, 2024
1 parent 9f37c2d commit b6b9b93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions jobs/resource_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ func (js *JobSettings) sortTasksByKey() {
func (js *JobSettings) adjustTasks() {
js.sortTasksByKey()
for _, task := range js.Tasks {
sort.Slice(task.DependsOn, func(i, j int) bool {
return task.DependsOn[i].TaskKey < task.DependsOn[j].TaskKey
})
sortWebhookNotifications(task.WebhookNotifications)
}
}
Expand Down
9 changes: 9 additions & 0 deletions jobs/resource_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,11 @@ func TestResourceJobCreate_JobClusters(t *testing.T) {
NodeTypeID: "b",
NumWorkers: 3,
},
DependsOn: []jobs.TaskDependency{
{
TaskKey: "a",
},
},
NotebookTask: &NotebookTask{
NotebookPath: "/Stuff",
},
Expand Down Expand Up @@ -537,6 +542,10 @@ func TestResourceJobCreate_JobClusters(t *testing.T) {
task {
task_key = "b"
depends_on {
task_key = "a"
}
new_cluster {
spark_version = "a"
node_type_id = "b"
Expand Down

0 comments on commit b6b9b93

Please sign in to comment.