-
Notifications
You must be signed in to change notification settings - Fork 154
Support serverless mode in default-python template (explicit prompt) #2377
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5a0de74
Support serverless in default-python with explicit prompt
denik 427e6c9
clean up serverless-auto tests
denik 79f2f38
clean up serverless 'auto' feature
denik 38f7e2c
clean up readme
denik 179a247
clean up
denik ee43de5
Remove full output in classic case, only keep the diff
denik 0b90f97
clean up unnecessary stub
denik 54781f9
Make serverless use 'main' catalog if it's not provided by API
denik 6f5dc05
fix whitespace & update tests
denik f8a1b6f
fix windows
denik 48ebd08
rebase and update tests
denik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
54 changes: 54 additions & 0 deletions
54
acceptance/bundle/templates/default-python/classic/out.compare-vs-serverless.diff
This file contains hidden or 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,54 @@ | ||
| --- [TESTROOT]/bundle/templates/default-python/classic/../serverless/output/my_default_python/resources/my_default_python.job.yml | ||
| +++ output/my_default_python/resources/my_default_python.job.yml | ||
| @@ -17,4 +17,5 @@ | ||
| tasks: | ||
| - task_key: notebook_task | ||
| + job_cluster_key: job_cluster | ||
| notebook_task: | ||
| notebook_path: ../src/notebook.ipynb | ||
| @@ -29,17 +30,21 @@ | ||
| depends_on: | ||
| - task_key: refresh_pipeline | ||
| - environment_key: default | ||
| + job_cluster_key: job_cluster | ||
| python_wheel_task: | ||
| package_name: my_default_python | ||
| entry_point: main | ||
| + libraries: | ||
| + # By default we just include the .whl file generated for the my_default_python package. | ||
| + # See https://docs.databricks.com/dev-tools/bundles/library-dependencies.html | ||
| + # for more information on how to add other libraries. | ||
| + - whl: ../dist/*.whl | ||
|
|
||
| - # A list of task execution environment specifications that can be referenced by tasks of this job. | ||
| - environments: | ||
| - - environment_key: default | ||
| - | ||
| - # Full documentation of this spec can be found at: | ||
| - # https://docs.databricks.com/api/workspace/jobs/create#environments-spec | ||
| - spec: | ||
| - client: "1" | ||
| - dependencies: | ||
| - - ../dist/*.whl | ||
| + job_clusters: | ||
| + - job_cluster_key: job_cluster | ||
| + new_cluster: | ||
| + spark_version: 15.4.x-scala2.12 | ||
| + node_type_id: i3.xlarge | ||
| + data_security_mode: SINGLE_USER | ||
| + autoscale: | ||
| + min_workers: 1 | ||
| + max_workers: 4 | ||
| --- [TESTROOT]/bundle/templates/default-python/classic/../serverless/output/my_default_python/resources/my_default_python.pipeline.yml | ||
| +++ output/my_default_python/resources/my_default_python.pipeline.yml | ||
| @@ -4,8 +4,7 @@ | ||
| my_default_python_pipeline: | ||
| name: my_default_python_pipeline | ||
| - ## Catalog is required for serverless compute | ||
| - catalog: main | ||
| + ## Specify the 'catalog' field to configure this pipeline to make use of Unity Catalog: | ||
| + # catalog: catalog_name | ||
| target: my_default_python_${bundle.target} | ||
| - serverless: true | ||
| libraries: | ||
| - notebook: |
File renamed without changes.
This file contains hidden or 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,15 @@ | ||
| trace $CLI bundle init default-python --config-file ./input.json --output-dir output | ||
|
|
||
| cd output/my_default_python | ||
| trace $CLI bundle validate -t dev | ||
| trace $CLI bundle validate -t prod | ||
|
|
||
| # Do not affect this repository's git behaviour #2318 | ||
| mv .gitignore out.gitignore | ||
|
|
||
| cd ../../ | ||
|
|
||
| # Calculate the difference from the serverless template | ||
| diff.py $TESTDIR/../serverless/output output/ > out.compare-vs-serverless.diff | ||
|
|
||
| rm -fr output |
22 changes: 22 additions & 0 deletions
22
acceptance/bundle/templates/default-python/serverless-customcatalog/output.txt
This file contains hidden or 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 @@ | ||
|
|
||
| >>> [CLI] bundle init default-python --config-file [TESTROOT]/bundle/templates/default-python/serverless-customcatalog/../serverless/input.json --output-dir output | ||
|
|
||
| Welcome to the default Python template for Databricks Asset Bundles! | ||
| Workspace to use (auto-detected, edit in 'my_default_python/databricks.yml'): [DATABRICKS_URL] | ||
|
|
||
| ✨ Your new project has been created in the 'my_default_python' directory! | ||
|
|
||
| Please refer to the README.md file for "getting started" instructions. | ||
| See also the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. | ||
|
|
||
| >>> diff.py [TESTROOT]/bundle/templates/default-python/serverless-customcatalog/../serverless/output output/ | ||
| --- [TESTROOT]/bundle/templates/default-python/serverless-customcatalog/../serverless/output/my_default_python/resources/my_default_python.pipeline.yml | ||
| +++ output/my_default_python/resources/my_default_python.pipeline.yml | ||
| @@ -4,6 +4,5 @@ | ||
| my_default_python_pipeline: | ||
| name: my_default_python_pipeline | ||
| - ## Catalog is required for serverless compute | ||
| - catalog: main | ||
| + catalog: customcatalog | ||
| target: my_default_python_${bundle.target} | ||
| serverless: true |
4 changes: 4 additions & 0 deletions
4
acceptance/bundle/templates/default-python/serverless-customcatalog/script
This file contains hidden or 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,4 @@ | ||
| trace $CLI bundle init default-python --config-file $TESTDIR/../serverless/input.json --output-dir output | ||
| mv output/my_default_python/.gitignore output/my_default_python/out.gitignore | ||
| trace diff.py $TESTDIR/../serverless/output output/ | ||
| rm -fr output |
8 changes: 8 additions & 0 deletions
8
acceptance/bundle/templates/default-python/serverless-customcatalog/test.toml
This file contains hidden or 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,8 @@ | ||
| [[Server]] | ||
| Pattern = "GET /api/2.1/unity-catalog/current-metastore-assignment" | ||
| Response.Body = '{"default_catalog_name": "customcatalog"}' | ||
|
|
||
| [[Repls]] | ||
| # windows fix | ||
| Old = '\\' | ||
| New = '/' |
7 changes: 7 additions & 0 deletions
7
acceptance/bundle/templates/default-python/serverless/input.json
This file contains hidden or 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 @@ | ||
| { | ||
| "project_name": "my_default_python", | ||
| "include_notebook": "yes", | ||
| "include_dlt": "yes", | ||
| "include_python": "yes", | ||
| "serverless": "yes" | ||
| } |
30 changes: 30 additions & 0 deletions
30
acceptance/bundle/templates/default-python/serverless/output.txt
This file contains hidden or 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,30 @@ | ||
|
|
||
| >>> [CLI] bundle init default-python --config-file ./input.json --output-dir output | ||
|
|
||
| Welcome to the default Python template for Databricks Asset Bundles! | ||
| Workspace to use (auto-detected, edit in 'my_default_python/databricks.yml'): [DATABRICKS_URL] | ||
|
|
||
| ✨ Your new project has been created in the 'my_default_python' directory! | ||
|
|
||
| Please refer to the README.md file for "getting started" instructions. | ||
| See also the documentation at https://docs.databricks.com/dev-tools/bundles/index.html. | ||
|
|
||
| >>> [CLI] bundle validate -t dev | ||
| Name: my_default_python | ||
| Target: dev | ||
| Workspace: | ||
| Host: [DATABRICKS_URL] | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/my_default_python/dev | ||
|
|
||
| Validation OK! | ||
|
|
||
| >>> [CLI] bundle validate -t prod | ||
| Name: my_default_python | ||
| Target: prod | ||
| Workspace: | ||
| Host: [DATABRICKS_URL] | ||
| User: [USERNAME] | ||
| Path: /Workspace/Users/[USERNAME]/.bundle/my_default_python/prod | ||
|
|
||
| Validation OK! |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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 hidden or 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
9 changes: 8 additions & 1 deletion
9
...s/default-python/template/{{.project_name}}/resources/{{.project_name}}.pipeline.yml.tmpl
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we use
noas default by the way?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the status quo. We can flip the switch any time, but the goal of this PR is to add this feature as an option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be yes since that's what we are promoting as a company. cc: @lennartkats-db @pietern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't disagree, but it can be a separate PR or we can decide to do it in a later version.
I'm also working on integration tests for standard templates (with deploy & summary & run), those would give more confidence in the new one.