-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the default
databricks bundle init
template more self-explanat…
…ory (#796) This makes the default-python template more self-explanatory and adds a few other tweaks for a better out-of-the-box experience.
- Loading branch information
1 parent
757d5ef
commit 0c1516c
Showing
8 changed files
with
72 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{{define "latest_lts_dbr_version" -}} | ||
13.3.x-scala2.12 | ||
{{- end}} | ||
|
||
{{define "latest_lts_db_connect_version_spec" -}} | ||
>=13.3,<13.4 | ||
{{- end}} |
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
22 changes: 22 additions & 0 deletions
22
libs/template/templates/default-python/template/{{.project_name}}/requirements-dev.txt.tmpl
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,22 @@ | ||
## requirements-dev.txt: dependencies for local development. | ||
## | ||
## For defining dependencies used by jobs in Databricks Workflows, see | ||
## https://docs.databricks.com/dev-tools/bundles/library-dependencies.html | ||
|
||
## pytest is the default package used for testing | ||
pytest | ||
|
||
## databricks-connect can be used to run parts of this project locally. | ||
## See https://docs.databricks.com/dev-tools/databricks-connect.html. | ||
## | ||
## databricks-connect is automatically installed if you're using Databricks | ||
## extension for Visual Studio Code | ||
## (https://docs.databricks.com/dev-tools/vscode-ext/dev-tasks/databricks-connect.html). | ||
## | ||
## To manually install databricks-connect, either follow the instructions | ||
## at https://docs.databricks.com/dev-tools/databricks-connect.html | ||
## to install the package system-wide. Or uncomment the line below to install a | ||
## version of db-connect that corresponds to the Databricks Runtime version used | ||
## for this project. | ||
# | ||
# databricks-connect{{template "latest_lts_db_connect_version_spec"}} |
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
16 changes: 16 additions & 0 deletions
16
libs/template/templates/default-python/template/{{.project_name}}/tests/main_test.py.tmpl
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 |
---|---|---|
@@ -1,5 +1,21 @@ | ||
from databricks.connect import DatabricksSession | ||
from pyspark.sql import SparkSession | ||
from {{.project_name}} import main | ||
|
||
# Create a new Databricks Connect session. If this fails, | ||
# check that you have configured Databricks Connect correctly. | ||
# See https://docs.databricks.com/dev-tools/databricks-connect.html. | ||
{{/* | ||
The below works around a problematic error message from Databricks Connect. | ||
The standard SparkSession is supported in all configurations (workspace, IDE, | ||
all runtime versions, CLI). But on the CLI it currently gives a confusing | ||
error message if SPARK_REMOTE is not set. We can't directly use | ||
DatabricksSession.builder in main.py, so we're re-assigning it here so | ||
everything works out of the box, even for CLI users who don't set SPARK_REMOTE. | ||
*/}} | ||
SparkSession.builder = DatabricksSession.builder | ||
SparkSession.builder.getOrCreate() | ||
|
||
def test_main(): | ||
taxis = main.get_taxis() | ||
assert taxis.count() > 5 |