-
Notifications
You must be signed in to change notification settings - Fork 121
Convert python wheel tests to acceptance #2396
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
Changes from all commits
2d373b5
6727be9
4102691
6a55de6
332130f
4c1d9fb
0d387d1
ea88f27
a7b0c8a
a96dfc4
7473399
c83c7bb
8950388
acdf1de
0af4a2d
3c06d8d
cb47517
3bca7e3
958163f
5591cfc
5143133
4f70738
cafb19e
0866d3c
58032d1
231a1df
59d7b59
35dae48
bfb88bc
25a6e62
62bad80
d04eb51
0ae3451
a01e88e
8c019a4
b7f2f79
b931eae
67d8ebe
7fbc751
98d3927
70d8d69
bd13b50
dcd100e
1b97ac3
d538e9e
f608aca
fe50cb1
176c247
8f65743
7dd0c0e
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,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)}") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,5 @@ | ||
| RecordRequests = false | ||
|
|
||
| [[Repls]] | ||
| Old = '\\' | ||
| New = '/' |
| 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 |
| 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 |
|---|---|---|
| @@ -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 |
| 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 |
|---|---|---|
| @@ -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" |
| 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 |
|---|---|---|
| @@ -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" |
| 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 |
| 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" |
| 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 |
| 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" |
| 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 |
|---|---|---|
| @@ -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... | ||
|
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. 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?
Contributor
Author
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 agree it's not ideal. I see this as -- we record a set of steps to be taken, ignoring the order.
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" | ||
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.
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?
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.
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.