-
Notifications
You must be signed in to change notification settings - Fork 233
Add libraries field to the clusters resource #6365
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
base: main
Are you sure you want to change the base?
Changes from all commits
6ad27d7
352669b
6d0278d
7c9526f
da49387
fc3d5c0
3fa6fb1
0771bfe
8c5552a
fe179e8
44a37b8
033c26d
25f701e
612add7
a0b4f3a
3e32ae9
0150cc9
ed672d7
690aa62
5ee3448
3ba91b8
f2a022a
bbbe43a
1b80d85
078f022
00895fe
7f40ac8
a9213b6
2219d01
6a2fba2
8e8cce3
aa6aa83
cc24040
35a1d8a
ff961cd
ccb2b43
c8af56d
d203128
7b3fe0b
82ea834
fe8d2dc
a3c0885
917ed09
99d38d4
032ae53
5ffa620
35b7b8c
840fcf3
917219f
112f4c6
003b598
459f91a
dca4944
bb35c3a
fe3505d
42c0fa9
b2decfe
3e966a7
e25a954
97e7e8c
18166f7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| * Add libraries field to clusters. ([#6365](https://github.com/databricks/cli/pull/6365)) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| bundle: | ||
| name: test-bundle-$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| clusters: | ||
| foo: | ||
| cluster_name: test-cluster-$UNIQUE_NAME | ||
| spark_version: 13.3.x-scala2.12 | ||
| node_type_id: $NODE_TYPE_ID | ||
| instance_pool_id: $TEST_INSTANCE_POOL_ID | ||
| num_workers: 1 | ||
| libraries: | ||
| - pypi: | ||
| package: requests |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| bundle: | ||
| name: cluster-libraries-$UNIQUE_NAME | ||
|
|
||
| workspace: | ||
| root_path: ~/.bundle/$UNIQUE_NAME | ||
|
|
||
| artifacts: | ||
| my_test_code: | ||
| type: whl | ||
| path: . | ||
| # Use 'python' because 'python3' does not exist in Windows virtualenvs. | ||
| build: python setup.py bdist_wheel | ||
|
|
||
| resources: | ||
| clusters: | ||
| mycluster: | ||
| cluster_name: mycluster-$UNIQUE_NAME | ||
| spark_version: $DEFAULT_SPARK_VERSION | ||
| node_type_id: $NODE_TYPE_ID | ||
| num_workers: 1 | ||
| data_security_mode: $DATA_SECURITY_MODE | ||
| libraries: | ||
| - whl: ./dist/*.whl |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| __version__ = "0.0.1" | ||
| __author__ = "Databricks" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| """ | ||
| The entry point of the Python Wheel | ||
| """ | ||
|
|
||
| import sys | ||
|
|
||
|
|
||
| def main(): | ||
| # This method will print the provided arguments | ||
| print("Hello from my func") | ||
| print("Got arguments:") | ||
| print(sys.argv) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
|
|
||
| === Deploy a cluster with a local wheel library | ||
| OK: cluster created with wheel | ||
|
|
||
| >>> print_requests.py //libraries/install | ||
| { | ||
| "method": "POST", | ||
| "path": "/api/2.0/libraries/install", | ||
| "body": { | ||
| "cluster_id": "[UUID]", | ||
| "libraries": [ | ||
| { | ||
| "whl": "/Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/artifacts/.internal/my_test_code-0.0.1-py3-none-any.whl" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| === Badness: wheel code changes but version does not, so redeploy neither reinstalls nor restarts | ||
| OK: no restart on content-only change (known limitation) | ||
|
|
||
| >>> print_requests.py //libraries/install | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.clusters.mycluster | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
|
|
||
| Destroy: 1 deleted |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| export DATA_SECURITY_MODE=USER_ISOLATION | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| rm -f out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| # Deploy output goes to LOG (differs fake vs cloud); echo a pass line instead. | ||
| title "Deploy a cluster with a local wheel library" | ||
| $CLI bundle deploy &> LOG.deploy | ||
| cat LOG.deploy | contains.py "Created clusters.mycluster" > /dev/null | ||
| printf '\n%s\n' "OK: cluster created with wheel" | ||
| trace print_requests.py //libraries/install | ||
|
|
||
| # Change only the wheel's code, keeping version 0.0.1 so the built filename - and | ||
| # thus the uploaded workspace path - is byte-for-byte identical to the first deploy. | ||
| title "Badness: wheel code changes but version does not, so redeploy neither reinstalls nor restarts" | ||
| update_file.py my_test_code/__main__.py "Hello from my func" "Hello from my func v2" | ||
| $CLI bundle deploy &> LOG.redeploy | ||
| # The libraries path is unchanged, so the plan sees no library change: the cluster is | ||
| # not restarted and no install request is issued, leaving the stale wheel running. The | ||
| # following two assertions encode that known limitation (see the TODO in cluster.go). | ||
| cat LOG.redeploy | contains.py "!Restarting cluster" > /dev/null | ||
| printf '\n%s\n' "OK: no restart on content-only change (known limitation)" | ||
| trace print_requests.py //libraries/install |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| uv venv -q .venv | ||
| venv_activate | ||
| uv pip install -q --no-index setuptools |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| from setuptools import setup, find_packages | ||
|
|
||
| import my_test_code | ||
|
|
||
| setup( | ||
| name="my_test_code", | ||
| version=my_test_code.__version__, | ||
| author=my_test_code.__author__, | ||
| url="https://databricks.com", | ||
| author_email="john.doe@databricks.com", | ||
| description="my example wheel", | ||
| packages=find_packages(include=["my_test_code"]), | ||
| entry_points={"group1": "run=my_test_code.__main__:main"}, | ||
| install_requires=["setuptools"], | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| Badness = "A local wheel whose contents change but whose version (and thus workspace path) does not is not detected in non-dev mode, so redeploy neither reinstalls it nor restarts the cluster; the stale wheel keeps running. See the TODO in bundle/direct/dresources/cluster.go DoUpdate." | ||
|
|
||
| Cloud = true | ||
| CloudSlow = true | ||
| RecordRequests = true | ||
|
|
||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
|
|
||
| Ignore = [".databricks", ".venv", "build", "dist", "my_test_code.egg-info", "databricks.yml"] | ||
|
|
||
| [[Repls]] | ||
| Old = "[0-9]{4}-[0-9]{6}-[0-9a-z]{8}" | ||
| New = "[UUID]" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| bundle: | ||
| name: libraries-readplan-not-uploaded | ||
|
|
||
| resources: | ||
| clusters: | ||
| mycluster: | ||
| cluster_name: mycluster | ||
| spark_version: 15.4.x-scala2.12 | ||
| node_type_id: Standard_DS3_v2 | ||
| num_workers: 1 | ||
| libraries: | ||
| # Prebuilt local wheel (no build: step) to keep the test hermetic. | ||
| - whl: ./dist/*.whl |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
|
|
||
| >>> [CLI] bundle plan -o json | ||
|
|
||
| >>> [CLI] bundle deploy --plan tmp.plan.json | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/libraries-readplan-not-uploaded/default/files... | ||
| Created clusters.mycluster | ||
| Files: 6 uploaded, 0 deleted | ||
| Resources: 1 created, 0 changed, 0 deleted, 0 unchanged | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.clusters.mycluster | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/libraries-readplan-not-uploaded/default | ||
|
|
||
| Destroy: 1 deleted |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| # A cluster's local wheel library is uploaded by `bundle deploy` but NOT by | ||
| # `bundle deploy --plan`. This tripwire pins that difference. | ||
| # Can be removed once fixed, and other tests can be moved to READPLAN variants. | ||
| #See acceptance/bundle/deploy/readplan/whl-not-uploaded for the bug. | ||
| trace $CLI bundle plan -o json > tmp.plan.json | ||
| trace $CLI bundle deploy --plan tmp.plan.json | ||
| trace $CLI bundle destroy --auto-approve |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Badness = "bundle deploy --plan skips the build phase, so a cluster's local wheel is never uploaded (proven in deploy/readplan/whl-not-uploaded). Kept as a note: when the bug is fixed, deploy --plan will print 'Uploading dist/...' and this golden changes - then delete this test and restore EnvMatrix.READPLAN = [\"\", \"1\"] on clusters/libraries and clusters/libraries-content-change." | ||
|
|
||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
| # This test is just asserting bad behaviour so that it can be removed once that behaviour is fixed | ||
| RecordRequests = false | ||
| Ignore = [".databricks", "tmp.plan.json"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| bundle: | ||
| name: cluster-libraries-repo-$UNIQUE_NAME | ||
|
|
||
| workspace: | ||
| root_path: ~/.bundle/$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| clusters: | ||
| mycluster: | ||
| cluster_name: mycluster-$UNIQUE_NAME | ||
| spark_version: $DEFAULT_SPARK_VERSION | ||
| node_type_id: $NODE_TYPE_ID | ||
| instance_pool_id: $TEST_INSTANCE_POOL_ID | ||
| num_workers: 1 | ||
| libraries: | ||
| - pypi: | ||
| package: requests | ||
| repo: https://pypi.org/simple |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
|
|
||
| === Deploy creates the cluster and installs the pypi library | ||
| OK: cluster created with pypi library | ||
|
|
||
| === Plan is a no-op after deploy: the repo round-trips | ||
| >>> [CLI] bundle plan | ||
| Plan: 0 to add, 0 to change, 0 to delete, 1 unchanged | ||
|
|
||
| === Changing only the repo is planned as an update | ||
| >>> [CLI] bundle plan | ||
| update clusters.mycluster | ||
|
|
||
| Plan: 0 to add, 1 to change, 0 to delete, 0 unchanged | ||
|
|
||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete resources.clusters.mycluster | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
|
|
||
| Destroy: 1 deleted |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| trace $CLI bundle destroy --auto-approve | ||
| rm -f out.requests.txt | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| # Deploy output goes to LOG (differs fake vs cloud); echo a pass line instead. | ||
| title "Deploy creates the cluster and installs the pypi library" | ||
| $CLI bundle plan -o json > tmp.plan.json 2>>LOG.plan | ||
| $CLI bundle deploy $(readplanarg tmp.plan.json) &> LOG.deploy | ||
| cat LOG.deploy | contains.py "Created clusters.mycluster" > /dev/null | ||
| printf '\n%s\n' "OK: cluster created with pypi library" | ||
|
|
||
| title "Plan is a no-op after deploy: the repo round-trips" | ||
| trace $CLI bundle plan | ||
|
|
||
| title "Changing only the repo is planned as an update" | ||
|
andrewnester marked this conversation as resolved.
|
||
| update_file.py databricks.yml "repo: https://pypi.org/simple" "repo: https://example.invalid/simple" | ||
| trace $CLI bundle plan | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| Cloud = true | ||
| CloudSlow = true | ||
| RecordRequests = false | ||
|
|
||
| EnvMatrix.DATABRICKS_BUNDLE_ENGINE = ["direct"] | ||
| EnvMatrix.READPLAN = ["", "1"] | ||
|
|
||
| Ignore = [".databricks", "databricks.yml", "tmp.plan.json"] | ||
|
|
||
| [[Repls]] | ||
| Old = "[0-9]{4}-[0-9]{6}-[0-9a-z]{8}" | ||
| New = "[UUID]" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| bundle: | ||
| name: cluster-libraries-restart-$UNIQUE_NAME | ||
|
|
||
| workspace: | ||
| root_path: ~/.bundle/$UNIQUE_NAME | ||
|
|
||
| resources: | ||
| clusters: | ||
| mycluster: | ||
| cluster_name: mycluster-$UNIQUE_NAME | ||
| spark_version: $DEFAULT_SPARK_VERSION | ||
| node_type_id: $NODE_TYPE_ID | ||
| instance_pool_id: $TEST_INSTANCE_POOL_ID | ||
| num_workers: 1 | ||
| libraries: | ||
| - pypi: | ||
| package: requests |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Isn't we already have a test for this?
Uh oh!
There was an error while loading. Please reload this page.
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 added this here as a reminder that once that issue is fixed READPLAN variants are added for tests here
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.
can we land the fix for build with --plan first? might affect the design here.