Skip to content
Open
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: 1 addition & 0 deletions .nextchanges/bundles/empty-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added an `empty` bundle template that scaffolds a bare `databricks.yml` and an empty `resources/` directory. Use it with `databricks bundle init empty` to start a new bundle without any sample code ([#5899](https://github.com/databricks/cli/pull/5899)).
1 change: 1 addition & 0 deletions acceptance/bundle/help/bundle-init/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TEMPLATE_PATH optionally specifies which template to use. It can be one of the f
- default-python: The default Python template for Notebooks and Lakeflow
- default-sql: The default SQL template for .sql files that run with Databricks SQL
- default-minimal: The minimal template, for advanced users
- empty: A bare bundle with just a databricks.yml and an empty resources directory
- default-scala: The default Scala template for JAR jobs
- dbt-sql: The dbt SQL template (databricks.com/blog/delivering-cost-effective-data-real-time-dbt-and-databricks)
- mlops-stacks: The Databricks MLOps Stacks template (github.com/databricks/mlops-stacks)
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/run/inline-script/no-bundle/output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

>>> [CLI] bundle run -- echo hello
Error: unable to locate bundle root: databricks.yml not found
Error: unable to locate bundle root: databricks.yml not found. Run 'databricks bundle init' to create a bundle, or run this command from a directory that already contains one


Exit code: 1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

>>> [CLI] bundle run echo hello
Error: unable to locate bundle root: databricks.yml not found
Error: unable to locate bundle root: databricks.yml not found. Run 'databricks bundle init' to create a bundle, or run this command from a directory that already contains one


Exit code: 1
3 changes: 3 additions & 0 deletions acceptance/bundle/templates/empty/input.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"project_name": "my_empty"
}
3 changes: 3 additions & 0 deletions acceptance/bundle/templates/empty/out.test.toml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions acceptance/bundle/templates/empty/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

>>> [CLI] bundle init empty --config-file ./input.json --output-dir output

Welcome to the empty template for Declarative Automation Bundles!

This template creates a bare-bones bundle with just a databricks.yml and an empty resources/ directory, ready for you to add your own jobs, pipelines, and other resources.

A workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.
workspace_host: [DATABRICKS_URL]

✨ Your new project has been created in the 'my_empty' directory!

Add resource definitions under my_empty/resources/, then deploy with:
cd my_empty
databricks bundle deploy

>>> [CLI] bundle validate -t dev
Name: my_empty
Target: dev
Workspace:
Host: [DATABRICKS_URL]
User: [USERNAME]
Path: /Workspace/Users/[USERNAME]/.bundle/my_empty/dev

Validation OK!
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.databricks/
18 changes: 18 additions & 0 deletions acceptance/bundle/templates/empty/output/my_empty/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This is a Declarative Automation Bundle definition for my_empty.
# See https://docs.databricks.com/dev-tools/bundles/index.html for documentation.
bundle:
name: my_empty

include:
- resources/*.yml

targets:
# The 'dev' target is the default target. It uses 'mode: development' to create
# development copies: deployed resources get prefixed with '[dev my_user_name]'
# and any schedules and triggers are paused by default.
# See https://docs.databricks.com/dev-tools/bundles/deployment-modes.html.
dev:
mode: development
default: true
workspace:
host: [DATABRICKS_URL]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

This folder is reserved for Declarative Automation Bundles resource definitions.
12 changes: 12 additions & 0 deletions acceptance/bundle/templates/empty/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trace $CLI bundle init empty --config-file ./input.json --output-dir output

cd output/my_empty

# Verify that the empty resources directory is preserved
[ -d "resources" ] || exit 1

trace $CLI bundle validate -t dev

rm -r .databricks

cd ../../
2 changes: 1 addition & 1 deletion bundle/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func getRootWithTraversal() (string, error) {
}
}

return "", fmt.Errorf(`unable to locate bundle root: %s not found`, config.FileNames[0])
return "", fmt.Errorf(`unable to locate bundle root: %s not found. Run 'databricks bundle init' to create a bundle, or run this command from a directory that already contains one`, config.FileNames[0])
}

// mustGetRoot returns a bundle root or an error if one cannot be found.
Expand Down
7 changes: 7 additions & 0 deletions libs/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type TemplateName string
const (
DefaultPython TemplateName = "default-python"
DefaultMinimal TemplateName = "default-minimal"
Empty TemplateName = "empty"
DefaultScala TemplateName = "default-scala"
ExperimentalDefaultPython TemplateName = "experimental-default-python-vnext"
DefaultSql TemplateName = "default-sql"
Expand Down Expand Up @@ -59,6 +60,12 @@ var databricksTemplates = []Template{
Reader: &builtinReader{name: string(DefaultMinimal)},
Writer: &writerWithFullTelemetry{defaultWriter: defaultWriter{name: DefaultMinimal}},
},
{
name: Empty,
description: "A bare bundle with just a databricks.yml and an empty resources directory",
Reader: &builtinReader{name: string(Empty)},
Writer: &writerWithFullTelemetry{defaultWriter: defaultWriter{name: Empty}},
},
{
name: DefaultScala,
description: "The default Scala template for JAR jobs",
Expand Down
3 changes: 3 additions & 0 deletions libs/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func TestTemplateHelpDescriptions(t *testing.T) {
expected := `- default-python: The default Python template for Notebooks and Lakeflow
- default-sql: The default SQL template for .sql files that run with Databricks SQL
- default-minimal: The minimal template, for advanced users
- empty: A bare bundle with just a databricks.yml and an empty resources directory
- default-scala: The default Scala template for JAR jobs
- dbt-sql: The dbt SQL template (databricks.com/blog/delivering-cost-effective-data-real-time-dbt-and-databricks)
- mlops-stacks: The Databricks MLOps Stacks template (github.com/databricks/mlops-stacks)
Expand All @@ -23,6 +24,7 @@ func TestTemplateOptions(t *testing.T) {
{Name: "default-python", Id: "The default Python template for Notebooks and Lakeflow"},
{Name: "default-sql", Id: "The default SQL template for .sql files that run with Databricks SQL"},
{Name: "default-minimal", Id: "The minimal template, for advanced users"},
{Name: "empty", Id: "A bare bundle with just a databricks.yml and an empty resources directory"},
{Name: "default-scala", Id: "The default Scala template for JAR jobs"},
{Name: "dbt-sql", Id: "The dbt SQL template (databricks.com/blog/delivering-cost-effective-data-real-time-dbt-and-databricks)"},
{Name: "mlops-stacks", Id: "The Databricks MLOps Stacks template (github.com/databricks/mlops-stacks)"},
Expand Down Expand Up @@ -58,6 +60,7 @@ func TestTemplateGetDatabricksTemplate(t *testing.T) {
names := []TemplateName{
DefaultPython,
DefaultMinimal,
Empty,
DefaultScala,
DefaultSql,
DbtSql,
Expand Down
14 changes: 14 additions & 0 deletions libs/template/templates/empty/databricks_template_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"welcome_message": "\nWelcome to the empty template for Declarative Automation Bundles!\n\nThis template creates a bare-bones bundle with just a databricks.yml and an empty resources/ directory, ready for you to add your own jobs, pipelines, and other resources.\n\nA workspace was selected based on your current profile. For information about how to change this, see https://docs.databricks.com/dev-tools/cli/profiles.html.\nworkspace_host: {{workspace_host}}",
"properties": {
"project_name": {
"type": "string",
"default": "my_bundle",
"description": "\nUnique name for this project.\nproject_name",
"order": 1,
"pattern": "^[A-Za-z0-9_]+$",
"pattern_match_failure_message": "Name must consist of letters, numbers, and underscores."
}
},
"success_message": "\n✨ Your new project has been created in the '{{.project_name}}' directory!\n\nAdd resource definitions under {{.project_name}}/resources/, then deploy with:\n cd {{.project_name}}\n databricks bundle deploy"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.databricks/
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This is a Declarative Automation Bundle definition for {{.project_name}}.
# See https://docs.databricks.com/dev-tools/bundles/index.html for documentation.
bundle:
name: {{.project_name}}

include:
- resources/*.yml

targets:
# The 'dev' target is the default target. It uses 'mode: development' to create
# development copies: deployed resources get prefixed with '[dev my_user_name]'
# and any schedules and triggers are paused by default.
# See https://docs.databricks.com/dev-tools/bundles/deployment-modes.html.
dev:
mode: development
default: true
workspace:
host: {{workspace_host}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

This folder is reserved for Declarative Automation Bundles resource definitions.
Loading