Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2d373b5
WIP
denik Feb 25, 2025
6727be9
add acc test
denik Feb 27, 2025
4102691
Convert python_wheel test to acceptance
denik Feb 27, 2025
6a55de6
set PYTHONDONTWRITEBYTECODE=1, add note about __pycache__
denik Feb 27, 2025
332130f
simplify stubbed response
denik Feb 27, 2025
4c1d9fb
move
denik Feb 27, 2025
0d387d1
update
denik Feb 27, 2025
ea88f27
update
denik Feb 27, 2025
a7b0c8a
add missing
denik Feb 27, 2025
a96dfc4
add python_wheel_no_build
denik Feb 27, 2025
7473399
clean up
denik Feb 27, 2025
c83c7bb
update
denik Feb 27, 2025
8950388
convert python_wheel_dbfs_lib
denik Feb 28, 2025
acdf1de
migrate multiple wheels
denik Feb 28, 2025
0af4a2d
add environment_key
denik Feb 28, 2025
3c06d8d
add no_artifact_no_setup
denik Feb 28, 2025
cb47517
update
denik Feb 28, 2025
3bca7e3
update
denik Feb 28, 2025
958163f
rename to databricks.yml
denik Feb 28, 2025
5591cfc
update
denik Feb 28, 2025
5143133
rename
denik Feb 28, 2025
4f70738
update
denik Feb 28, 2025
cafb19e
update
denik Feb 28, 2025
0866d3c
rename
denik Feb 28, 2025
58032d1
update
denik Feb 28, 2025
231a1df
cleanup
denik Feb 28, 2025
59d7b59
update
denik Feb 28, 2025
35dae48
rename
denik Feb 28, 2025
bfb88bc
rename
denik Feb 28, 2025
25a6e62
cleanup
denik Feb 28, 2025
62bad80
fix duplicate
denik Feb 28, 2025
d04eb51
fixes
denik Feb 28, 2025
0ae3451
clean up
denik Feb 28, 2025
a01e88e
clean up
denik Feb 28, 2025
8c019a4
clean up
denik Feb 28, 2025
b7f2f79
clean up
denik Feb 28, 2025
b931eae
chore: Add virtual env setup to script.prepare
denik Feb 28, 2025
67d8ebe
fix: use correct venv activation path for Windows in script.prepare
denik Feb 28, 2025
7fbc751
set up venv with uv
denik Feb 28, 2025
98d3927
fixes
denik Feb 28, 2025
70d8d69
ruff
denik Feb 28, 2025
bd13b50
fix shebang
denik Feb 28, 2025
dcd100e
fix slashes in find.py on windows
denik Feb 28, 2025
1b97ac3
ruff
denik Feb 28, 2025
d538e9e
fix windows - do not use python3, it is not part of virtualenv
denik Feb 28, 2025
f608aca
clean up unnecessary rm
denik Feb 28, 2025
fe50cb1
clean up
denik Feb 28, 2025
176c247
use jq -s '.[] | X' instead of 'jq -s X', this helps on windows
denik Feb 28, 2025
8f65743
sort results in find.py; more use of 'jq -s'
denik Feb 28, 2025
7dd0c0e
add comments
denik Feb 28, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions acceptance/bin/find.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
"""
Usage: find.py <regex>
Finds all files within current directory matching regex. The output is sorted and slashes are always forward.

If --expect N is provided, the number of matches must be N or error is printed.
"""

import sys
import os
import re
import argparse


parser = argparse.ArgumentParser()
parser.add_argument("regex")
parser.add_argument("--expect", type=int)
args = parser.parse_args()

regex = re.compile(args.regex)
result = []

for root, dirs, files in os.walk("."):
for filename in files:
path = os.path.join(root, filename).lstrip("./\\").replace("\\", "/")
if regex.search(path):
result.append(path)

result.sort()
for item in result:
print(item)
sys.stdout.flush()

if args.expect is not None:
if args.expect != len(result):
sys.exit(f"Expected {args.expect}, got {len(result)}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inclusion of an expectation in this command feels off.

Could we compose this with a function/command/helper that asserts on the number of lines in an output?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this is not a generic command, this is an acceptance test helper. Given its narrow context, I think it's okay.

If we see more use cases where a separate line-counting script would makes things simpler, we can always extract that.

2 changes: 2 additions & 0 deletions acceptance/bundle/artifacts/same_name_libraries/test.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
RecordRequests = false

[[Repls]]
Old = '\\'
New = '/'
9 changes: 9 additions & 0 deletions acceptance/bundle/artifacts/script.prepare
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export PYTHONDONTWRITEBYTECODE=1

uv venv -q --python 3.12 .venv
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then
source .venv/Scripts/activate
else
source .venv/bin/activate
fi
uv pip install -q setuptools
18 changes: 18 additions & 0 deletions acceptance/bundle/artifacts/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Cloud = false
RecordRequests = true
Ignore = [
'.venv',
'dist',
'build',
'*egg-info',
'.databricks',
]

[[Server]]
Pattern = "GET /api/2.1/clusters/get"
Response.Body = '''
{
"cluster_id": "0717-132531-5opeqon1",
"spark_version": "13.3.x-scala2.12"
}
'''
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Cloud = false
RecordRequests = false

# The order in which files are uploaded can be different, so we just replace the name
[[Repls]]
Expand Down
32 changes: 32 additions & 0 deletions acceptance/bundle/artifacts/whl_dbfs/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

>>> [CLI] bundle deploy
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/python-wheel/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

=== Expecting to find no wheels
>>> errcode find.py --expect 0 whl

=== Expecting 1 wheel in libraries section in /jobs/create
>>> jq -s .[] | select(.path=="/api/2.1/jobs/create") | .body.tasks out.requests.txt
[
{
"existing_cluster_id": "0717-132531-5opeqon1",
"libraries": [
{
"whl": "dbfs:/path/to/dist/mywheel.whl"
}
],
"python_wheel_task": {
"entry_point": "run",
"package_name": "my_test_code"
},
"task_key": "TestTask"
}
]

=== Expecting no wheels to be uploaded
>>> errcode sh -c jq .path < out.requests.txt | grep import | grep whl

Exit code: 1
12 changes: 12 additions & 0 deletions acceptance/bundle/artifacts/whl_dbfs/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trace $CLI bundle deploy

title "Expecting to find no wheels"
trace errcode find.py --expect 0 whl

title "Expecting 1 wheel in libraries section in /jobs/create"
trace jq -s '.[] | select(.path=="/api/2.1/jobs/create") | .body.tasks' out.requests.txt

title "Expecting no wheels to be uploaded"
trace errcode sh -c 'jq .path < out.requests.txt | grep import | grep whl'

rm out.requests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ artifacts:
my_test_code:
type: whl
path: "./my_test_code"
build: "python3 setup.py bdist_wheel"
# using 'python' there because 'python3' does not exist in virtualenv on windows
build: python setup.py bdist_wheel

resources:
jobs:
Expand Down
34 changes: 34 additions & 0 deletions acceptance/bundle/artifacts/whl_explicit/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

>>> [CLI] bundle deploy
Building my_test_code...
Uploading my_test_code-0.0.1-py3-none-any.whl...
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/python-wheel/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> find.py --expect 1 whl
my_test_code/dist/my_test_code-0.0.1-py3-none-any.whl

=== Expecting 1 wheel in libraries section in /jobs/create
>>> jq -s .[] | select(.path=="/api/2.1/jobs/create") | .body.tasks out.requests.txt
[
{
"existing_cluster_id": "0717-132531-5opeqon1",
"libraries": [
{
"whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1-py3-none-any.whl"
}
],
"python_wheel_task": {
"entry_point": "run",
"package_name": "my_test_code"
},
"task_key": "TestTask"
}
]

=== Expecting 1 wheel 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-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"
11 changes: 11 additions & 0 deletions acceptance/bundle/artifacts/whl_explicit/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
trace $CLI bundle deploy

trace find.py --expect 1 whl

title "Expecting 1 wheel in libraries section in /jobs/create"
trace jq -s '.[] | select(.path=="/api/2.1/jobs/create") | .body.tasks' out.requests.txt

title "Expecting 1 wheel to be uploaded"
trace jq .path < out.requests.txt | grep import | grep whl | sort

rm out.requests.txt
34 changes: 34 additions & 0 deletions acceptance/bundle/artifacts/whl_implicit/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

>>> [CLI] bundle deploy
Building python_artifact...
Uploading my_test_code-0.0.1-py3-none-any.whl...
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/python-wheel/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> find.py --expect 1 whl
dist/my_test_code-0.0.1-py3-none-any.whl

=== Expecting 1 wheels in libraries section in /jobs/create
>>> jq -s .[] | select(.path=="/api/2.1/jobs/create") | .body.tasks out.requests.txt
[
{
"existing_cluster_id": "0717-aaaaa-bbbbbb",
"libraries": [
{
"whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1-py3-none-any.whl"
}
],
"python_wheel_task": {
"entry_point": "run",
"package_name": "my_test_code"
},
"task_key": "TestTask"
}
]

=== Expecting 1 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-py3-none-any.whl"
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/files/dist/my_test_code-0.0.1-py3-none-any.whl"
11 changes: 11 additions & 0 deletions acceptance/bundle/artifacts/whl_implicit/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
trace $CLI bundle deploy

trace find.py --expect 1 whl

title "Expecting 1 wheels in libraries section in /jobs/create"
trace jq -s '.[] | select(.path=="/api/2.1/jobs/create") | .body.tasks' out.requests.txt

title "Expecting 1 wheels to be uploaded"
trace jq .path < out.requests.txt | grep import | grep whl | sort

rm out.requests.txt
46 changes: 46 additions & 0 deletions acceptance/bundle/artifacts/whl_implicit_custom_path/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

>>> [CLI] bundle deploy
Uploading my_test_code-0.0.1-py3-none-any.whl...
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/python-wheel-local/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> find.py --expect 1 whl
package/my_test_code-0.0.1-py3-none-any.whl

=== Expecting 1 wheel in libraries section in /jobs/create
>>> jq -s .[] | select(.path=="/api/2.1/jobs/create") | .body out.requests.txt
{
"deployment": {
"kind": "BUNDLE",
"metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/python-wheel-local/default/state/metadata.json"
},
"edit_mode": "UI_LOCKED",
"format": "MULTI_TASK",
"max_concurrent_runs": 1,
"name": "[default] My Wheel Job",
"queue": {
"enabled": true
},
"tasks": [
{
"existing_cluster_id": "0717-aaaaa-bbbbbb",
"libraries": [
{
"whl": "/Workspace/foo/bar/.internal/my_test_code-0.0.1-py3-none-any.whl"
}
],
"python_wheel_task": {
"entry_point": "run",
"package_name": "my_test_code"
},
"task_key": "TestTask"
}
]
}

=== Expecting 1 wheel to be uploaded
>>> jq .path
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel-local/default/files/package/my_test_code-0.0.1-py3-none-any.whl"
"/api/2.0/workspace-files/import-file/Workspace/foo/bar/.internal/my_test_code-0.0.1-py3-none-any.whl"
11 changes: 11 additions & 0 deletions acceptance/bundle/artifacts/whl_implicit_custom_path/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
trace $CLI bundle deploy

trace find.py --expect 1 whl

title "Expecting 1 wheel in libraries section in /jobs/create"
trace jq -s '.[] | select(.path=="/api/2.1/jobs/create") | .body' out.requests.txt

title "Expecting 1 wheel to be uploaded"
trace jq .path < out.requests.txt | grep import | grep whl | sort

rm out.requests.txt
33 changes: 33 additions & 0 deletions acceptance/bundle/artifacts/whl_implicit_notebook/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

>>> [CLI] bundle deploy
Building python_artifact...
Uploading my_test_code-0.0.1-py3-none-any.whl...
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/python-wheel-notebook/default/files...
Deploying resources...
Updating deployment state...
Deployment complete!

>>> find.py --expect 1 whl
dist/my_test_code-0.0.1-py3-none-any.whl

=== Expecting 1 wheel in libraries section in /jobs/create
>>> jq -s .[] | select(.path=="/api/2.1/jobs/create") | .body.tasks out.requests.txt
[
{
"existing_cluster_id": "0717-aaaaa-bbbbbb",
"libraries": [
{
"whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel-notebook/default/artifacts/.internal/my_test_code-0.0.1-py3-none-any.whl"
}
],
"notebook_task": {
"notebook_path": "/notebook.py"
},
"task_key": "TestTask"
}
]

=== Expecting 1 wheel to be uploaded
>>> jq .path
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel-notebook/default/artifacts/.internal/my_test_code-0.0.1-py3-none-any.whl"
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel-notebook/default/files/dist/my_test_code-0.0.1-py3-none-any.whl"
11 changes: 11 additions & 0 deletions acceptance/bundle/artifacts/whl_implicit_notebook/script
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
trace $CLI bundle deploy

trace find.py --expect 1 whl

title "Expecting 1 wheel in libraries section in /jobs/create"
trace jq -s '.[] | select(.path=="/api/2.1/jobs/create") | .body.tasks' out.requests.txt

title "Expecting 1 wheel to be uploaded"
trace jq .path < out.requests.txt | grep import | grep whl | sort

rm out.requests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ artifacts:
my_test_code:
type: whl
path: "./my_test_code"
build: "python3 setup.py bdist_wheel"
build: "python setup.py bdist_wheel"
my_test_code_2:
type: whl
path: "./my_test_code"
build: "python3 setup2.py bdist_wheel"
build: "python setup2.py bdist_wheel"

resources:
jobs:
Expand Down
42 changes: 42 additions & 0 deletions acceptance/bundle/artifacts/whl_multiple/output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

>>> [CLI] bundle deploy
Building my_test_code...
Building my_test_code_2...
Deploying resources...
Deployment complete!
Updating deployment state...
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/python-wheel/default/files...
Uploading my_test_code-0.0.1-py3-none-any.whl...
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order is a bit confusing now, shall we do the package name replacement instead in these lines and then the output will be determenistic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's not ideal. I see this as -- we record a set of steps to be taken, ignoring the order.

do the package name replacement

I'd rather see the names, given that we focus on multiple wheels being supported there. If we replace both, we won't catch situation if it uploaded one wheel twice instead of two separate wheels once.

Uploading my_test_code_2-0.0.1-py3-none-any.whl...

>>> find.py --expect 2 whl
my_test_code/dist/my_test_code-0.0.1-py3-none-any.whl
my_test_code/dist/my_test_code_2-0.0.1-py3-none-any.whl

=== Expecting 2 wheels in libraries section in /jobs/create
>>> jq -s .[] | select(.path=="/api/2.1/jobs/create") | .body.tasks out.requests.txt
[
{
"existing_cluster_id": "0717-132531-5opeqon1",
"libraries": [
{
"whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code-0.0.1-py3-none-any.whl"
},
{
"whl": "/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code_2-0.0.1-py3-none-any.whl"
}
],
"python_wheel_task": {
"entry_point": "run",
"package_name": "my_test_code"
},
"task_key": "TestTask"
}
]

=== Expecting 2 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-py3-none-any.whl"
"/api/2.0/workspace-files/import-file/Workspace/Users/[USERNAME]/.bundle/python-wheel/default/artifacts/.internal/my_test_code_2-0.0.1-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/my_test_code/dist/my_test_code_2-0.0.1-py3-none-any.whl"
Loading