Skip to content

Enable 'num_workers: 0' default on jobs #2792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion acceptance/bundle/debug/out.stderr.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
10:07:59 Debug: ApplyParallel pid=12345 mutator=validate:validate_sync_patterns
10:07:59 Debug: ApplyParallel pid=12345 mutator=fast_validate(readonly) mutator=validate:job_cluster_key_defined
10:07:59 Debug: ApplyParallel pid=12345 mutator=fast_validate(readonly) mutator=validate:job_task_cluster_spec
10:07:59 Debug: ApplyParallel pid=12345 mutator=fast_validate(readonly) mutator=validate:SingleNodeCluster
10:07:59 Debug: ApplyParallel pid=12345 mutator=fast_validate(readonly) mutator=validate:artifact_paths
10:07:59 Debug: GET /api/2.0/workspace/get-status?path=/Workspace/Users/[USERNAME]/.bundle/debug/default/files
< HTTP/1.1 404 Not Found
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
},
"data_security_mode": "SINGLE_USER",
"node_type_id": "[NODE_TYPE_ID]",
"num_workers": 0,
"spark_version": "15.4.x-scala2.12"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,33 @@ Resources:
+ "id": "[NUMBER]",
"job_clusters": [
{
@@ -61,5 +62,4 @@
@@ -55,5 +56,4 @@
"data_security_mode": "SINGLE_USER",
"node_type_id": "[NODE_TYPE_ID]",
- "num_workers": 0,
"spark_version": "15.4.x-scala2.12"
}
@@ -62,5 +62,4 @@
"max_concurrent_runs": 4,
"name": "[dev [USERNAME]] project_name_[UNIQUE_NAME]_job",
- "permissions": [],
"queue": {
"enabled": true
@@ -112,5 +112,6 @@
@@ -113,5 +112,6 @@
"unit": "DAYS"
}
- }
+ },
+ "url": "[DATABRICKS_URL]/jobs/[NUMBER]"
}
},
@@ -127,4 +128,5 @@
@@ -128,4 +128,5 @@
"development": true,
"edition": "ADVANCED",
+ "id": "[UUID]",
"libraries": [
{
@@ -135,6 +137,6 @@
@@ -136,6 +137,6 @@
],
"name": "[dev [USERNAME]] project_name_[UNIQUE_NAME]_pipeline",
- "permissions": [],
Expand All @@ -89,7 +95,7 @@ Resources:
+ "url": "[DATABRICKS_URL]/pipelines/[UUID]"
}
}
@@ -145,5 +147,4 @@
@@ -146,5 +147,4 @@
]
},
- "targets": null,
Expand Down Expand Up @@ -168,7 +174,7 @@ Validation OK!
+ "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/prod/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
@@ -59,12 +51,9 @@
@@ -60,12 +52,9 @@
}
],
- "max_concurrent_runs": 4,
Expand All @@ -183,21 +189,21 @@ Validation OK!
- "dev": "[USERNAME]"
},
"tasks": [
@@ -72,5 +61,5 @@
@@ -73,5 +62,5 @@
"job_cluster_key": "job_cluster",
"notebook_task": {
- "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src/notebook"
+ "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/prod/files/src/notebook"
},
"task_key": "notebook_task"
@@ -107,5 +96,5 @@
@@ -108,5 +97,5 @@
],
"trigger": {
- "pause_status": "PAUSED",
+ "pause_status": "UNPAUSED",
"periodic": {
"interval": 1,
@@ -119,22 +108,21 @@
@@ -120,22 +109,21 @@
"channel": "CURRENT",
"configuration": {
- "bundle.sourcePath": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src"
Expand Down Expand Up @@ -225,7 +231,7 @@ Validation OK!
+ "schema": "project_name_[UNIQUE_NAME]_prod"
}
}
@@ -147,10 +135,10 @@
@@ -148,10 +136,10 @@
"targets": null,
"workspace": {
- "artifact_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/artifacts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Warning: Ignoring Databricks CLI version constraint for development build. Requi
},
"data_security_mode": "SINGLE_USER",
"node_type_id": "i3.xlarge",
"num_workers": 0,
"spark_version": "15.4.x-scala2.12"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"node_type_id": "Standard_DS3_v2"
"node_type_id": "Standard_DS3_v2",
"num_workers": 0
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func ApplyBundlePermissions() bundle.Mutator {
}

func (m *bundlePermissions) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
err := validate(b)
err := validatePermissions(b)
if err != nil {
return diag.FromErr(err)
}
Expand Down Expand Up @@ -119,7 +119,7 @@ func (m *bundlePermissions) Apply(ctx context.Context, b *bundle.Bundle) diag.Di
return nil
}

func validate(b *bundle.Bundle) error {
func validatePermissions(b *bundle.Bundle) error {
for _, p := range b.Config.Permissions {
if !slices.Contains(allowedLevels, p.Level) {
return fmt.Errorf("invalid permission level: %s, allowed values: [%s]", p.Level, strings.Join(allowedLevels, ", "))
Expand Down
5 changes: 4 additions & 1 deletion bundle/config/mutator/resourcemutator/resource_mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"

"github.com/databricks/cli/bundle/config/mutator"
"github.com/databricks/cli/bundle/config/validate"

"github.com/databricks/cli/libs/dyn/merge"

Expand Down Expand Up @@ -38,6 +39,8 @@ func applyInitializeMutators(ctx context.Context, b *bundle.Bundle) diag.Diagnos

// ApplyPresets should have more priority than defaults below, so it should be run first
ApplyPresets(),

validate.SingleNodeCluster(),
)

if diags.HasError() {
Expand Down Expand Up @@ -68,7 +71,7 @@ func applyInitializeMutators(ctx context.Context, b *bundle.Bundle) diag.Diagnos

// https://github.com/databricks/terraform-provider-databricks/blob/v1.75.0/clusters/resource_cluster.go
// This triggers SingleNodeCluster() cluster validator. It needs to be run before applying defaults.
//{"resources.jobs.*.job_clusters[*].new_cluster.num_workers", 0},
{"resources.jobs.*.job_clusters[*].new_cluster.num_workers", 0},
{"resources.jobs.*.job_clusters[*].new_cluster.workload_type.clients.notebooks", true},
{"resources.jobs.*.job_clusters[*].new_cluster.workload_type.clients.jobs", true},

Expand Down
1 change: 0 additions & 1 deletion bundle/config/validate/fast_validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func (f *fastValidate) Apply(ctx context.Context, rb *bundle.Bundle) diag.Diagno
// Fast mutators with only in-memory checks
JobClusterKeyDefined(),
JobTaskClusterSpec(),
SingleNodeCluster(),

// Blocking mutators. Deployments will fail if these checks fail.
ValidateArtifactPath(),
Expand Down
Loading