Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 214
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
2d373b56727be941026916a55de6332130f4c1d9fb0d387d1ea88f27a7b0c8aa96dfc47473399c83c7bb8950388acdf1de0af4a2d3c06d8dcb475173bca7e3958163f5591cfc51431334f70738cafb19e0866d3c58032d1231a1df59d7b5935dae48bfb88bc25a6e6262bad80d04eb510ae3451a01e88e8c019a4b7f2f79b931eae67d8ebe7fbc75198d392770d8d69bd13b50dcd100e1b97ac3d538e9ef608acafe50cb1176c2478f657437dd0c0eFile 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,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? 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. 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" | ||
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.
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.