-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable environment overrides for job tasks (#779)
## Changes Follow up for #658 When a job definition has multiple job tasks using the same key, it's considered invalid. Instead we should combine those definitions with the same key into one. This is consistent with environment overrides. This way, the override ends up in the original job tasks, and we've got a clear way to put them all together. ## Tests Added unit tests
- Loading branch information
1 parent
b3b00fd
commit 43e2eef
Showing
6 changed files
with
179 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
bundle: | ||
name: override_job_tasks | ||
|
||
workspace: | ||
host: https://acme.cloud.databricks.com/ | ||
|
||
resources: | ||
jobs: | ||
foo: | ||
name: job | ||
tasks: | ||
- task_key: key1 | ||
new_cluster: | ||
spark_version: 13.3.x-scala2.12 | ||
spark_python_task: | ||
python_file: ./test1.py | ||
- task_key: key2 | ||
new_cluster: | ||
spark_version: 13.3.x-scala2.12 | ||
spark_python_task: | ||
python_file: ./test2.py | ||
|
||
targets: | ||
development: | ||
resources: | ||
jobs: | ||
foo: | ||
tasks: | ||
- task_key: key1 | ||
new_cluster: | ||
node_type_id: i3.xlarge | ||
num_workers: 1 | ||
|
||
staging: | ||
resources: | ||
jobs: | ||
foo: | ||
tasks: | ||
- task_key: key2 | ||
new_cluster: | ||
node_type_id: i3.2xlarge | ||
num_workers: 4 | ||
spark_python_task: | ||
python_file: ./test3.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package config_tests | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestOverrideTasksDev(t *testing.T) { | ||
b := loadTarget(t, "./override_job_tasks", "development") | ||
assert.Equal(t, "job", b.Config.Resources.Jobs["foo"].Name) | ||
assert.Len(t, b.Config.Resources.Jobs["foo"].Tasks, 2) | ||
|
||
tasks := b.Config.Resources.Jobs["foo"].Tasks | ||
assert.Equal(t, tasks[0].TaskKey, "key1") | ||
assert.Equal(t, tasks[0].NewCluster.NodeTypeId, "i3.xlarge") | ||
assert.Equal(t, tasks[0].NewCluster.NumWorkers, 1) | ||
assert.Equal(t, tasks[0].SparkPythonTask.PythonFile, "./test1.py") | ||
|
||
assert.Equal(t, tasks[1].TaskKey, "key2") | ||
assert.Equal(t, tasks[1].NewCluster.SparkVersion, "13.3.x-scala2.12") | ||
assert.Equal(t, tasks[1].SparkPythonTask.PythonFile, "./test2.py") | ||
} | ||
|
||
func TestOverrideTasksStaging(t *testing.T) { | ||
b := loadTarget(t, "./override_job_tasks", "staging") | ||
assert.Equal(t, "job", b.Config.Resources.Jobs["foo"].Name) | ||
assert.Len(t, b.Config.Resources.Jobs["foo"].Tasks, 2) | ||
|
||
tasks := b.Config.Resources.Jobs["foo"].Tasks | ||
assert.Equal(t, tasks[0].TaskKey, "key1") | ||
assert.Equal(t, tasks[0].NewCluster.SparkVersion, "13.3.x-scala2.12") | ||
assert.Equal(t, tasks[0].SparkPythonTask.PythonFile, "./test1.py") | ||
|
||
assert.Equal(t, tasks[1].TaskKey, "key2") | ||
assert.Equal(t, tasks[1].NewCluster.NodeTypeId, "i3.2xlarge") | ||
assert.Equal(t, tasks[1].NewCluster.NumWorkers, 4) | ||
assert.Equal(t, tasks[1].SparkPythonTask.PythonFile, "./test3.py") | ||
} |