Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 214
Implement dynamic_version attribute in artifacts section#2520
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
8064e06a0d65e40388ba3b9b6e07bb1c77113ee78b7f71b64f6b03021b36e6e9f9a541f9bd32b72d8f519bd1c9a6b5f5ed424212e18fd31bd67d0591dfde8a9f5f06b7b20557File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/usr/bin/env python3 | ||
| """ | ||
| List files in zip archive | ||
| """ | ||
| import sys | ||
| import zipfile | ||
| from pathlib import Path | ||
| for zip_path in sys.argv[1:]: | ||
| with zipfile.ZipFile(zip_path.strip()) as z: | ||
| for info in z.infolist(): | ||
| print(info.filename) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| bundle: | ||
| name: python-wheel | ||
| artifacts: | ||
| my_test_code: | ||
| type: whl | ||
| path: "./my_test_code" | ||
| # using 'python' there because 'python3' does not exist in virtualenv on windows | ||
| build: python setup.py bdist_wheel | ||
| dynamic_version: true | ||
| my_prebuilt_whl: | ||
| type: whl | ||
| files: | ||
| - source: prebuilt/other_test_code-0.0.1-py3-none-any.whl | ||
| dynamic_version: true | ||
| resources: | ||
| jobs: | ||
| test_job: | ||
| name: "[${bundle.target}] My Wheel Job" | ||
| tasks: | ||
| - task_key: TestTask | ||
| existing_cluster_id: "0717-132531-5opeqon1" | ||
| python_wheel_task: | ||
| package_name: "my_test_code" | ||
| entry_point: "run" | ||
| libraries: | ||
| - whl: ./my_test_code/dist/*.whl | ||
| - whl: prebuilt/other_test_code-0.0.1-py3-none-any.whl | ||
| for_each_task: | ||
| inputs: "[1]" | ||
| task: | ||
| task_key: SubTask | ||
| existing_cluster_id: "0717-132531-5opeqon1" | ||
| python_wheel_task: | ||
| package_name: "my_test_code" | ||
| entry_point: "run" | ||
| libraries: | ||
| - whl: ./my_test_code/dist/*.whl | ||
| - task_key: ServerlessTestTask | ||
| python_wheel_task: | ||
| package_name: "my_test_code" | ||
| entry_point: "run" | ||
| environment_key: "test_env" | ||
| environments: | ||
| - environment_key: "test_env" | ||
| spec: | ||
| client: "1" | ||
| dependencies: | ||
| - ./my_test_code/dist/*.whl |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| >>> [CLI] bundle validate -o json | ||
| { | ||
| "my_prebuilt_whl": { | ||
| "dynamic_version": true, | ||
| "files": [ | ||
| { | ||
| "source": "[TEST_TMP_DIR]/prebuilt/other_test_code-0.0.1-py3-none-any.whl" | ||
| } | ||
| ], | ||
| "path": "[TEST_TMP_DIR]", | ||
| "type": "whl" | ||
| }, | ||
| "my_test_code": { | ||
| "build": "python setup.py bdist_wheel", | ||
| "dynamic_version": true, | ||
| "path": "[TEST_TMP_DIR]/my_test_code", | ||
| "type": "whl" | ||
| } | ||
| } | ||
| >>> [CLI] bundle deploy | ||
| Building my_test_code... | ||
| Uploading .databricks/bundle/default/patched_wheels/my_prebuilt_whl_other_test_code/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl... | ||
| Uploading .databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl... | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/python-wheel/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
| === There are 2 original wheels and 2 patched ones | ||
| >>> find.py --expect 4 whl | ||
| .databricks/bundle/default/patched_wheels/my_prebuilt_whl_other_test_code/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl | ||
| .databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl | ||
| my_test_code/dist/my_test_code-0.0.1-py3-none-any.whl | ||
| prebuilt/other_test_code-0.0.1-py3-none-any.whl | ||
| === Verify contents of the zip file | ||
| >>> find.py --expect 1 .databricks/.*my_test_code.*whl | ||
| src/__init__.py | ||
| src/__main__.py | ||
| my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/METADATA | ||
| my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/WHEEL | ||
| my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/entry_points.txt | ||
| my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/top_level.txt | ||
| my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/RECORD | ||
| === Expecting 2 patched wheels in libraries section in /jobs/create | ||
| >>> jq -s .[] | select(.path=="/api/2.1/jobs/create") | .body.tasks out.requests.txt | ||
| [ | ||
| { | ||
| "environment_key": "test_env", | ||
| "python_wheel_task": { | ||
| "entry_point": "run", | ||
| "package_name": "my_test_code" | ||
| }, | ||
| "task_key": "ServerlessTestTask" | ||
| }, | ||
| { | ||
| "existing_cluster_id": "0717-132531-5opeqon1", | ||
| "for_each_task": { | ||
| "inputs": "[1]", | ||
| "task": { | ||
| "existing_cluster_id": "0717-132531-5opeqon1", | ||
| "libraries": [ | ||
| { | ||
| "whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl" | ||
| } | ||
| ], | ||
| "python_wheel_task": { | ||
| "entry_point": "run", | ||
| "package_name": "my_test_code" | ||
| }, | ||
| "task_key": "SubTask" | ||
| } | ||
| }, | ||
| "libraries": [ | ||
| { | ||
| "whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl" | ||
| }, | ||
| { | ||
| "whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl" | ||
| } | ||
| ], | ||
| "python_wheel_task": { | ||
| "entry_point": "run", | ||
| "package_name": "my_test_code" | ||
| }, | ||
| "task_key": "TestTask" | ||
| } | ||
| ] | ||
| === Expecting 2 patched wheels to be uploaded | ||
| >>> jq .path | ||
| "/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl" | ||
| "/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl" | ||
| "/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/files/my_test_code/dist/my_test_code-0.0.1-py3-none-any.whl" | ||
| "/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/files/prebuilt/other_test_code-0.0.1-py3-none-any.whl" | ||
| === Updating the local wheel and deploying again | ||
| >>> [CLI] bundle deploy | ||
| Building my_test_code... | ||
| Uploading .databricks/bundle/default/patched_wheels/my_prebuilt_whl_other_test_code/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl... | ||
| Uploading .databricks/bundle/default/patched_wheels/my_test_code_my_test_code/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl... | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/python-wheel/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
| === Verify contents, it should now have new_module.py | ||
| >>> find.py --expect 1 .databricks/.*my_test_code.*whl | ||
| src/__init__.py | ||
| src/__main__.py | ||
| src/new_module.py | ||
| my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/METADATA | ||
| my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/WHEEL | ||
| my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/entry_points.txt | ||
| my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/top_level.txt | ||
| my_test_code-0.0.1+[TIMESTAMP_NS].dist-info/RECORD | ||
| === Expecting 2 patched wheels in libraries section in /jobs/reset | ||
| >>> jq -s .[] | select(.path=="/api/2.1/jobs/reset") | .body.new_settings.tasks out.requests.txt | ||
| [ | ||
| { | ||
| "environment_key": "test_env", | ||
| "python_wheel_task": { | ||
| "entry_point": "run", | ||
| "package_name": "my_test_code" | ||
| }, | ||
| "task_key": "ServerlessTestTask" | ||
| }, | ||
| { | ||
| "existing_cluster_id": "0717-132531-5opeqon1", | ||
| "for_each_task": { | ||
| "inputs": "[1]", | ||
| "task": { | ||
| "existing_cluster_id": "0717-132531-5opeqon1", | ||
| "libraries": [ | ||
| { | ||
| "whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl" | ||
| } | ||
| ], | ||
| "python_wheel_task": { | ||
| "entry_point": "run", | ||
| "package_name": "my_test_code" | ||
| }, | ||
| "task_key": "SubTask" | ||
| } | ||
| }, | ||
| "libraries": [ | ||
| { | ||
| "whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl" | ||
| }, | ||
| { | ||
| "whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl" | ||
| } | ||
| ], | ||
| "python_wheel_task": { | ||
| "entry_point": "run", | ||
| "package_name": "my_test_code" | ||
| }, | ||
| "task_key": "TestTask" | ||
| } | ||
| ] | ||
| === Expecting 2 pached wheels to be uploaded (Bad: it is currently uploaded twice) | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I expect ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, maybe it's not bad. I wonder if we could do a better job regardless of whether .gitignore is present, since we know this file to be output. | ||
| >>> jq .path | ||
| "/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl" | ||
| "/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/other_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl" | ||
| "/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/files/my_test_code/dist/my_test_code-0.0.1-py3-none-any.whl" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| trap "rm -fr out.requests.txt databricks.yml my_test_code prebuilt" EXIT | ||
| cp -r $TESTDIR/../whl_explicit/my_test_code . | ||
| mkdir prebuilt | ||
| cp -r $TESTDIR/../whl_prebuilt_multiple/dist/lib/other_test_code-0.0.1-py3-none-any.whl prebuilt | ||
| trace $CLI bundle validate -o json | jq .artifacts | ||
| trace $CLI bundle deploy | ||
| title "There are 2 original wheels and 2 patched ones" | ||
| trace find.py --expect 4 whl | ||
| title "Verify contents of the zip file" | ||
| trace find.py --expect 1 '.databricks/.*my_test_code.*whl' | xargs ziplist.py | ||
| title "Expecting 2 patched wheels in libraries section in /jobs/create" | ||
| trace jq -s '.[] | select(.path=="/api/2.1/jobs/create") | .body.tasks' out.requests.txt | ||
| title "Expecting 2 patched wheels to be uploaded" | ||
| trace jq .path < out.requests.txt | grep import | grep whl | sort | ||
| rm out.requests.txt | ||
| title "Updating the local wheel and deploying again" | ||
| touch my_test_code/src/new_module.py | ||
| trace $CLI bundle deploy | ||
| title "Verify contents, it should now have new_module.py" | ||
| trace find.py --expect 1 '.databricks/.*my_test_code.*whl' | xargs ziplist.py | ||
| title "Expecting 2 patched wheels in libraries section in /jobs/reset" | ||
| trace jq -s '.[] | select(.path=="/api/2.1/jobs/reset") | .body.new_settings.tasks' out.requests.txt | ||
| title "Expecting 2 pached wheels to be uploaded (Bad: it is currently uploaded twice)" | ||
| trace jq .path < out.requests.txt | grep import | grep whl | sort |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [[Repls]] | ||
| Old = '\\\\' | ||
| New = '/' | ||
| [[Server]] | ||
| Pattern = "POST /api/2.1/jobs/reset" | ||
| Response.Body = '{}' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| bundle: | ||
| name: wheel-task | ||
| workspace: | ||
| root_path: "~/.bundle/$UNIQUE_NAME" | ||
| artifacts: | ||
| python_artifact: | ||
| type: whl | ||
| build: uv build --wheel | ||
| files: | ||
| - source: dist/*.whl | ||
| dynamic_version: true | ||
| resources: | ||
| clusters: | ||
| test_cluster: | ||
| cluster_name: "test-cluster-$UNIQUE_NAME" | ||
| spark_version: "$DEFAULT_SPARK_VERSION" | ||
| node_type_id: "$NODE_TYPE_ID" | ||
| num_workers: 1 | ||
| data_security_mode: $DATA_SECURITY_MODE | ||
| jobs: | ||
| some_other_job: | ||
| name: "[${bundle.target}] Test Wheel Job $UNIQUE_NAME" | ||
| tasks: | ||
| - task_key: TestTask | ||
| existing_cluster_id: "${resources.clusters.test_cluster.cluster_id}" | ||
| python_wheel_task: | ||
| package_name: my_test_code | ||
| entry_point: run | ||
| parameters: | ||
| - "one" | ||
| - "two" | ||
| libraries: | ||
| - whl: ./dist/*.whl |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| >>> [CLI] bundle deploy | ||
| Building python_artifact... | ||
| Uploading .databricks/bundle/default/patched_wheels/python_artifact_my_test_code/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl... | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
| >>> [CLI] bundle run some_other_job | ||
| Run URL: [DATABRICKS_URL]/?o=[NUMID]#job/[NUMID]/run/[NUMID] | ||
| [TIMESTAMP] "[default] Test Wheel Job [UNIQUE_NAME]" RUNNING | ||
| [TIMESTAMP] "[default] Test Wheel Job [UNIQUE_NAME]" TERMINATED SUCCESS | ||
| Hello from my func | ||
| Got arguments: | ||
| ['my_test_code', 'one', 'two'] | ||
| === Make a change to code without version change and run the job again | ||
| >>> [CLI] bundle deploy | ||
| Building python_artifact... | ||
| Uploading .databricks/bundle/default/patched_wheels/python_artifact_my_test_code/my_test_code-0.0.1+[TIMESTAMP_NS]-py3-none-any.whl... | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
| >>> [CLI] bundle run some_other_job | ||
| Run URL: [DATABRICKS_URL]/?o=[NUMID]#job/[NUMID]/run/[NUMID] | ||
| [TIMESTAMP] "[default] Test Wheel Job [UNIQUE_NAME]" RUNNING | ||
| [TIMESTAMP] "[default] Test Wheel Job [UNIQUE_NAME]" TERMINATED SUCCESS | ||
| UPDATED MY FUNC | ||
| Got arguments: | ||
| ['my_test_code', 'one', 'two'] | ||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete cluster test_cluster | ||
| delete job some_other_job | ||
| All files and directories at the following location will be deleted: /Workspace/Users/[USERNAME]/.bundle/[UNIQUE_NAME] | ||
| Deleting files... | ||
| Destroy complete! |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
| cp -r $TESTDIR/../interactive_cluster/{setup.py,my_test_code} . | ||
| trap "errcode trace '$CLI' bundle destroy --auto-approve" EXIT | ||
| trace $CLI bundle deploy | ||
| trace $CLI bundle run some_other_job | ||
| title "Make a change to code without version change and run the job again" | ||
| update_file.py my_test_code/__main__.py 'Hello from my func' 'UPDATED MY FUNC' | ||
| trace $CLI bundle deploy | ||
| trace $CLI bundle run some_other_job |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| [EnvMatrix] | ||
| DATA_SECURITY_MODE = [ | ||
| "USER_ISOLATION", | ||
| "SINGLE_USER", | ||
| ] | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do these run locally as well? ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, integration_whl only runs as integration. | ||
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.
This is an internal path. Not great, but I'm not sure if special-casing this is better...