Skip to content

Commit 6508433

Browse files
denikpietern
andauthored
Simplify & fix default configuration for whl artifacts (#2987)
## Changes - Insert regular glob into default settings instead of custom function for finding wheels. - Remove code to explicitly fail the build if wheels are not found. ## Why - Helps in #2982 where we modify glob expansion to filter out same-name wheels. - Failed build will stop deploy regardless, because there is return code check and glob expansion check, no need for custom code there. - Simpler & more consistent behaviour: whl behave like those without 'type: whl'. ## Tests Existing tests. --------- Co-authored-by: Pieter Noordhuis <pieter.noordhuis@databricks.com>
1 parent 33106ba commit 6508433

8 files changed

Lines changed: 54 additions & 49 deletions

File tree

acceptance/bundle/artifacts/build_and_files_whl/databricks.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
artifacts:
22
artifact_with_custom_dist:
3-
# commenting out 'type: whl' here actually makes 'bundle deploy' to build and upload correct wheel,
4-
# because for non-whl types it does respect 'files' section.
53
type: whl
64
build: python setup.py bdist_wheel --dist-dir mydist
75
files:

acceptance/bundle/artifacts/build_and_files_whl/output.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Validation OK!
1010

1111
>>> errcode [CLI] bundle deploy
1212
Building artifact_with_custom_dist...
13-
Error: cannot find built wheel in [TEST_TMP_DIR] for package artifact_with_custom_dist
14-
15-
16-
Exit code: 1
13+
Uploading mydist/my_test_code-0.0.1-py3-none-any.whl...
14+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/default/files...
15+
Deploying resources...
16+
Deployment complete!
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
Badness = "artifacts of type 'whl' hard-code dist directory even if explicit files section is present"
21
RecordRequests = false

acceptance/bundle/artifacts/whl_dynamic/output.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
"my_test_code": {
1515
"build": "python setup.py bdist_wheel",
1616
"dynamic_version": true,
17+
"files": [
18+
{
19+
"source": "[TEST_TMP_DIR]/my_test_code/dist/*.whl"
20+
}
21+
],
1722
"path": "[TEST_TMP_DIR]/my_test_code",
1823
"type": "whl"
1924
}

acceptance/bundle/templates/default-python/integration_classic/out.validate.dev.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
"artifacts": {
33
"python_artifact": {
44
"build": "python3 setup.py bdist_wheel",
5+
"files": [
6+
{
7+
"source": "[TEST_TMP_DIR]/project_name_[UNIQUE_NAME]/dist/*.whl"
8+
}
9+
],
510
"path": "[TEST_TMP_DIR]/project_name_[UNIQUE_NAME]",
611
"type": "whl"
712
}

acceptance/bundle/templates/default-python/integration_classic/output.txt

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,39 +54,46 @@ Resources:
5454
>>> diff.py ../out.validate.dev.json ../out.summary.dev.json
5555
--- ../out.validate.dev.json
5656
+++ ../out.summary.dev.json
57-
@@ -45,4 +45,5 @@
57+
@@ -5,4 +5,6 @@
58+
"files": [
59+
{
60+
+ "patched": "",
61+
+ "remote_path": "",
62+
"source": "[TEST_TMP_DIR]/project_name_[UNIQUE_NAME]/dist/*.whl"
63+
}
64+
@@ -50,4 +52,5 @@
5865
"edit_mode": "UI_LOCKED",
5966
"format": "MULTI_TASK",
6067
+ "id": "[NUMID]",
6168
"job_clusters": [
6269
{
63-
@@ -55,5 +56,4 @@
70+
@@ -60,5 +63,4 @@
6471
"data_security_mode": "SINGLE_USER",
6572
"node_type_id": "[NODE_TYPE_ID]",
6673
- "num_workers": 0,
6774
"spark_version": "15.4.x-scala2.12"
6875
}
69-
@@ -62,5 +62,4 @@
76+
@@ -67,5 +69,4 @@
7077
"max_concurrent_runs": 4,
7178
"name": "[dev [USERNAME]] project_name_[UNIQUE_NAME]_job",
7279
- "permissions": [],
7380
"queue": {
7481
"enabled": true
75-
@@ -113,5 +112,6 @@
82+
@@ -118,5 +119,6 @@
7683
"unit": "DAYS"
7784
}
7885
- }
7986
+ },
8087
+ "url": "[DATABRICKS_URL]/jobs/[NUMID]"
8188
}
8289
},
83-
@@ -128,4 +128,5 @@
90+
@@ -133,4 +135,5 @@
8491
"development": true,
8592
"edition": "ADVANCED",
8693
+ "id": "[UUID]",
8794
"libraries": [
8895
{
89-
@@ -136,6 +137,6 @@
96+
@@ -141,6 +144,6 @@
9097
],
9198
"name": "[dev [USERNAME]] project_name_[UNIQUE_NAME]_pipeline",
9299
- "permissions": [],
@@ -95,7 +102,7 @@ Resources:
95102
+ "url": "[DATABRICKS_URL]/pipelines/[UUID]"
96103
}
97104
}
98-
@@ -146,5 +147,4 @@
105+
@@ -151,5 +154,4 @@
99106
]
100107
},
101108
- "targets": null,
@@ -127,7 +134,7 @@ Validation OK!
127134
>>> diff.py ../out.validate.dev.json ../out.validate.prod.json
128135
--- ../out.validate.dev.json
129136
+++ ../out.validate.prod.json
130-
@@ -8,16 +8,11 @@
137+
@@ -13,16 +13,11 @@
131138
},
132139
"bundle": {
133140
- "deployment": {
@@ -147,7 +154,7 @@ Validation OK!
147154
+ "target": "prod",
148155
"terraform": {},
149156
"uuid": "[UUID]"
150-
@@ -27,13 +22,10 @@
157+
@@ -32,13 +27,10 @@
151158
"resources/project_name_[UNIQUE_NAME].pipeline.yml"
152159
],
153160
- "presets": {
@@ -167,14 +174,14 @@ Validation OK!
167174
+ ],
168175
"resources": {
169176
"jobs": {
170-
@@ -41,5 +33,5 @@
177+
@@ -46,5 +38,5 @@
171178
"deployment": {
172179
"kind": "BUNDLE",
173180
- "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/state/metadata.json"
174181
+ "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/prod/state/metadata.json"
175182
},
176183
"edit_mode": "UI_LOCKED",
177-
@@ -60,12 +52,9 @@
184+
@@ -65,12 +57,9 @@
178185
}
179186
],
180187
- "max_concurrent_runs": 4,
@@ -189,21 +196,21 @@ Validation OK!
189196
- "dev": "[USERNAME]"
190197
},
191198
"tasks": [
192-
@@ -73,5 +62,5 @@
199+
@@ -78,5 +67,5 @@
193200
"job_cluster_key": "job_cluster",
194201
"notebook_task": {
195202
- "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src/notebook"
196203
+ "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/prod/files/src/notebook"
197204
},
198205
"task_key": "notebook_task"
199-
@@ -108,5 +97,5 @@
206+
@@ -113,5 +102,5 @@
200207
],
201208
"trigger": {
202209
- "pause_status": "PAUSED",
203210
+ "pause_status": "UNPAUSED",
204211
"periodic": {
205212
"interval": 1,
206-
@@ -120,22 +109,21 @@
213+
@@ -125,22 +114,21 @@
207214
"channel": "CURRENT",
208215
"configuration": {
209216
- "bundle.sourcePath": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src"
@@ -231,7 +238,7 @@ Validation OK!
231238
+ "schema": "project_name_[UNIQUE_NAME]_prod"
232239
}
233240
}
234-
@@ -148,10 +136,10 @@
241+
@@ -153,10 +141,10 @@
235242
"targets": null,
236243
"workspace": {
237244
- "artifact_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/artifacts",
@@ -278,7 +285,7 @@ Resources:
278285
>>> diff.py ../out.summary.dev.json ../out.summary.prod.json
279286
--- ../out.summary.dev.json
280287
+++ ../out.summary.prod.json
281-
@@ -9,15 +9,13 @@
288+
@@ -16,15 +16,13 @@
282289
"bundle": {
283290
"deployment": {
284291
- "lock": {
@@ -298,7 +305,7 @@ Resources:
298305
+ "target": "prod",
299306
"terraform": {},
300307
"uuid": "[UUID]"
301-
@@ -27,13 +25,11 @@
308+
@@ -34,13 +32,11 @@
302309
"resources/project_name_[UNIQUE_NAME].pipeline.yml"
303310
],
304311
- "presets": {
@@ -319,14 +326,14 @@ Resources:
319326
+ "presets": {},
320327
"resources": {
321328
"jobs": {
322-
@@ -41,5 +37,5 @@
329+
@@ -48,5 +44,5 @@
323330
"deployment": {
324331
"kind": "BUNDLE",
325332
- "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/state/metadata.json"
326333
+ "metadata_file_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/prod/state/metadata.json"
327334
},
328335
"edit_mode": "UI_LOCKED",
329-
@@ -60,11 +56,8 @@
336+
@@ -67,11 +63,8 @@
330337
}
331338
],
332339
- "max_concurrent_runs": 4,
@@ -340,21 +347,21 @@ Resources:
340347
- "dev": "[USERNAME]"
341348
},
342349
"tasks": [
343-
@@ -72,5 +65,5 @@
350+
@@ -79,5 +72,5 @@
344351
"job_cluster_key": "job_cluster",
345352
"notebook_task": {
346353
- "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src/notebook"
347354
+ "notebook_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/prod/files/src/notebook"
348355
},
349356
"task_key": "notebook_task"
350-
@@ -107,5 +100,5 @@
357+
@@ -114,5 +107,5 @@
351358
],
352359
"trigger": {
353360
- "pause_status": "PAUSED",
354361
+ "pause_status": "UNPAUSED",
355362
"periodic": {
356363
"interval": 1,
357-
@@ -120,11 +113,10 @@
364+
@@ -127,11 +120,10 @@
358365
"channel": "CURRENT",
359366
"configuration": {
360367
- "bundle.sourcePath": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src"
@@ -368,7 +375,7 @@ Resources:
368375
- "development": true,
369376
"edition": "ADVANCED",
370377
"id": "[UUID]",
371-
@@ -132,10 +124,10 @@
378+
@@ -139,10 +131,10 @@
372379
{
373380
"notebook": {
374381
- "path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/files/src/dlt_pipeline"
@@ -382,7 +389,7 @@ Resources:
382389
+ "schema": "project_name_[UNIQUE_NAME]_prod",
383390
"url": "[DATABRICKS_URL]/pipelines/[UUID]"
384391
}
385-
@@ -148,10 +140,10 @@
392+
@@ -155,10 +147,10 @@
386393
},
387394
"workspace": {
388395
- "artifact_path": "/Workspace/Users/[USERNAME]/.bundle/project_name_[UNIQUE_NAME]/dev/artifacts",

bundle/artifacts/build.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"github.com/databricks/cli/libs/exec"
1515
"github.com/databricks/cli/libs/log"
1616
"github.com/databricks/cli/libs/patchwheel"
17-
"github.com/databricks/cli/libs/python"
1817
"github.com/databricks/cli/libs/utils"
1918
)
2019

@@ -51,23 +50,6 @@ func (m *build) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics {
5150
break
5251
}
5352

54-
if a.Type == "whl" {
55-
dir := a.Path
56-
distPath := filepath.Join(a.Path, "dist")
57-
wheels := python.FindFilesWithSuffixInPath(distPath, ".whl")
58-
if len(wheels) == 0 {
59-
diags = diags.Extend(diag.Errorf("cannot find built wheel in %s for package %s", dir, artifactName))
60-
break
61-
}
62-
for _, wheel := range wheels {
63-
a.Files = append(a.Files, config.ArtifactFile{
64-
Source: wheel,
65-
})
66-
}
67-
} else {
68-
log.Warnf(ctx, "%s: Build succeeded", artifactName)
69-
}
70-
7153
// We need to expand glob reference after build mutator is applied because
7254
// if we do it before, any files that are generated by build command will
7355
// not be included into artifact.Files and thus will not be uploaded.

bundle/artifacts/prepare.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ func (m *prepare) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics
4242
if artifact.BuildCommand == "" && len(artifact.Files) == 0 {
4343
artifact.BuildCommand = python.GetExecutable() + " setup.py bdist_wheel"
4444
}
45+
46+
// Wheel builds write to `./dist`. Pick up all wheel files by default if nothing is specified.
47+
if len(artifact.Files) == 0 {
48+
artifact.Files = []config.ArtifactFile{
49+
{
50+
Source: filepath.Join(artifact.Path, "dist", "*.whl"),
51+
},
52+
}
53+
}
4554
}
4655

4756
l := b.Config.GetLocation("artifacts." + artifactName)

0 commit comments

Comments
 (0)