Improve default template (#1046)

## Changes
- Tweak strings, documentation in template
- Extend requirements-dev.txt with setuptools/wheel for building whl
files
- Clarify what the "_job.yml" file is for for users who are only
interested in DLT pipelines (answering a question that came up recently)

## Tests
Existing tests exercise this template
This commit is contained in:
Lennart Kats (databricks) 2023-12-11 20:13:14 +01:00 committed by GitHub
parent 42c06267eb
commit 8b9930a49a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 30 deletions

View File

@ -1,10 +1,10 @@
{ {
"welcome_message": "\nWelcome to the sample Databricks Asset Bundle template! Please enter the following information to initialize your sample DAB.\n", "welcome_message": "\nWelcome to the default Python template for Databricks Asset Bundles!",
"properties": { "properties": {
"project_name": { "project_name": {
"type": "string", "type": "string",
"default": "my_project", "default": "my_project",
"description": "Unique name for this project", "description": "Please provide the following details to tailor the template to your preferences.\n\nUnique name for this project",
"order": 1, "order": 1,
"pattern": "^[A-Za-z0-9_]+$", "pattern": "^[A-Za-z0-9_]+$",
"pattern_match_failure_message": "Name must consist of letters, numbers, and underscores." "pattern_match_failure_message": "Name must consist of letters, numbers, and underscores."
@ -31,5 +31,5 @@
"order": 4 "order": 4
} }
}, },
"success_message": "\n✨ Your new project has been created in the '{{.project_name}}' directory!\n\nPlease refer to the README.md of your project for further instructions on getting started.\nOr read the documentation on Databricks Asset Bundles at https://docs.databricks.com/dev-tools/bundles/index.html." "success_message": "Workspace to use (auto-detected, edit in '{{.project_name}}/databricks.yml'): {{workspace_host}}\n\n✨ Your new project has been created in the '{{.project_name}}' directory!\n\nPlease refer to the README.md file for \"getting started\" instructions.\nSee also the documentation at https://docs.databricks.com/dev-tools/bundles/index.html."
} }

View File

@ -1,4 +1,3 @@
.databricks/ .databricks/
build/ build/
dist/ dist/

View File

@ -28,7 +28,7 @@ The '{{.project_name}}' project was generated by using the default-python templa
$ databricks bundle deploy --target prod $ databricks bundle deploy --target prod
``` ```
5. To run a job or pipeline, use the "run" comand: 5. To run a job or pipeline, use the "run" command:
``` ```
$ databricks bundle run $ databricks bundle run
``` ```

View File

@ -7,46 +7,36 @@ include:
- resources/*.yml - resources/*.yml
targets: targets:
# The 'dev' target, used for development purposes. # The 'dev' target, for development purposes. This target is the default.
# Whenever a developer deploys using 'dev', they get their own copy.
dev: dev:
# We use 'mode: development' to make sure everything deployed to this target gets a prefix # We use 'mode: development' to indicate this is a personal development copy:
# like '[dev my_user_name]'. Setting this mode also disables any schedules and # - Deployed resources get prefixed with '[dev my_user_name]'
# automatic triggers for jobs and enables the 'development' mode for Delta Live Tables pipelines. # - Any job schedules and triggers are paused by default
# - The 'development' mode is used for Delta Live Tables pipelines
mode: development mode: development
default: true default: true
workspace: workspace:
host: {{workspace_host}} host: {{workspace_host}}
# Optionally, there could be a 'staging' target here. ## Optionally, there could be a 'staging' target here.
# (See Databricks docs on CI/CD at https://docs.databricks.com/dev-tools/bundles/index.html.) ## (See Databricks docs on CI/CD at https://docs.databricks.com/dev-tools/bundles/index.html.)
# #
# staging: # staging:
# workspace: # workspace:
# host: {{workspace_host}} # host: {{workspace_host}}
# The 'prod' target, used for production deployment. # The 'prod' target, used for production deployment.
prod: prod:
# For production deployments, we only have a single copy, so we override the # We use 'mode: production' to indicate this is a production deployment.
# workspace.root_path default of # Doing so enables strict verification of the settings below.
# /Users/${workspace.current_user.userName}/.bundle/${bundle.target}/${bundle.name}
# to a path that is not specific to the current user.
{{- /*
Explaining 'mode: production' isn't as pressing as explaining 'mode: development'.
As we already talked about the other mode above, users can just
look at documentation or ask the assistant about 'mode: production'.
#
# By making use of 'mode: production' we enable strict checks
# to make sure we have correctly configured this target.
*/}}
mode: production mode: production
workspace: workspace:
host: {{workspace_host}} host: {{workspace_host}}
# We only have a single deployment copy for production, so we use a shared path.
root_path: /Shared/.bundle/prod/${bundle.name} root_path: /Shared/.bundle/prod/${bundle.name}
{{- if not is_service_principal}} {{- if not is_service_principal}}
run_as: run_as:
# This runs as {{user_name}} in production. Alternatively, # This runs as {{user_name}} in production. We could also use a service principal here
# a service principal could be used here using service_principal_name # using service_principal_name (see https://docs.databricks.com/dev-tools/bundles/permissions.html).
# (see Databricks documentation).
user_name: {{user_name}} user_name: {{user_name}}
{{end -}} {{end -}}

View File

@ -6,6 +6,10 @@
## pytest is the default package used for testing ## pytest is the default package used for testing
pytest pytest
## Dependencies for building wheel files
setuptools
wheel
## databricks-connect can be used to run parts of this project locally. ## databricks-connect can be used to run parts of this project locally.
## See https://docs.databricks.com/dev-tools/databricks-connect.html. ## See https://docs.databricks.com/dev-tools/databricks-connect.html.
## ##

View File

@ -1,10 +1,17 @@
# The main job for {{.project_name}} # The main job for {{.project_name}}.
{{- /* Clarify what this job is for for DLT-only users. */}}
{{if and (eq .include_dlt "yes") (and (eq .include_notebook "no") (eq .include_python "no")) -}}
# This job runs {{.project_name}}_pipeline on a schedule.
{{end -}}
resources: resources:
jobs: jobs:
{{.project_name}}_job: {{.project_name}}_job:
name: {{.project_name}}_job name: {{.project_name}}_job
schedule: schedule:
# Run every day at 8:37 AM
quartz_cron_expression: '44 37 8 * * ?' quartz_cron_expression: '44 37 8 * * ?'
timezone_id: Europe/Amsterdam timezone_id: Europe/Amsterdam