Skip to content

Commit 360a6a7

Browse files
authored
Fix #3109: default search location for whl artifacts (#3184)
## Changes When initializing `artifacts.*.files.source` to default `<Path>/dist/*.whl` we used to (in version 0.254.0 and earlier) first to initialize path to bundle root then join it with "dist/*.whl". After #2987 we switched to first initializing Files.Source then initializing Path, thus breaking some cases, see #3109 ## Tests New acceptance regression test, reproduces #3109 without this PR ebffb67
1 parent 1867a02 commit 360a6a7

File tree

9 files changed

+67
-15
lines changed

9 files changed

+67
-15
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include:
2+
- src/job1/databricks_job/resources/*.yaml
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Local = true
2+
Cloud = false
3+
4+
[EnvMatrix]
5+
DATABRICKS_CLI_DEPLOYMENT = ["terraform", "direct-exp"]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Building wheels...
2+
Uploading dist/my_default_python-0.0.1-py3-none-any.whl...
3+
Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/test-bundle/dev/files...
4+
Deploying resources...
5+
Updating deployment state...
6+
Deployment complete!
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[project]
2+
name = "my_default_python"
3+
version = "0.0.1"
4+
authors = [{ name = "[USERNAME]" }]
5+
requires-python = ">= 3.11"
6+
7+
[build-system]
8+
requires = ["hatchling"]
9+
build-backend = "hatchling.build"
10+
11+
[tool.hatch.build.targets.wheel]
12+
packages = ["src/job1/databricks_job"]
13+
14+
[project.scripts]
15+
main = "my_default_python.main:main"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$CLI bundle deploy --target dev

acceptance/bundle/artifacts/issue_3109/src/job1/databricks_job/hello_job1.py

Whitespace-only changes.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
targets:
2+
dev:
3+
mode: development
4+
artifacts:
5+
wheels:
6+
type: whl
7+
build: "uv build --wheel"
8+
resources:
9+
jobs:
10+
job1:
11+
name: job1
12+
tasks:
13+
- task_key: wheel_task
14+
job_cluster_key: job_cluster
15+
python_wheel_task:
16+
package_name: job1_databricks_job
17+
job_clusters:
18+
- job_cluster_key: job_cluster
19+
new_cluster:
20+
spark_version: 11.3.x-scala2.12
21+
node_type_id: i3.xlarge
22+
num_workers: 2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
RecordRequests = false

bundle/artifacts/prepare.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,6 @@ func (m *prepare) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics
4949
b.Metrics.AddBoolValue(metrics.ArtifactBuildCommandIsSet, artifact.BuildCommand != "")
5050
b.Metrics.AddBoolValue(metrics.ArtifactFilesIsSet, len(artifact.Files) != 0)
5151

52-
if artifact.Type == "whl" {
53-
if artifact.BuildCommand == "" && len(artifact.Files) == 0 {
54-
artifact.BuildCommand = python.GetExecutable() + " setup.py bdist_wheel"
55-
}
56-
57-
// Wheel builds write to `./dist`. Pick up all wheel files by default if nothing is specified.
58-
if len(artifact.Files) == 0 {
59-
artifact.Files = []config.ArtifactFile{
60-
{
61-
Source: filepath.Join(artifact.Path, "dist", "*.whl"),
62-
},
63-
}
64-
}
65-
}
66-
6752
l := b.Config.GetLocation("artifacts." + artifactName)
6853
dirPath := filepath.Dir(l.File)
6954

@@ -79,6 +64,21 @@ func (m *prepare) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnostics
7964
artifact.Path = b.BundleRootPath
8065
}
8166

67+
if artifact.Type == "whl" {
68+
if artifact.BuildCommand == "" && len(artifact.Files) == 0 {
69+
artifact.BuildCommand = python.GetExecutable() + " setup.py bdist_wheel"
70+
}
71+
72+
// Wheel builds write to `./dist`. Pick up all wheel files by default if nothing is specified.
73+
if len(artifact.Files) == 0 {
74+
artifact.Files = []config.ArtifactFile{
75+
{
76+
Source: filepath.Join(artifact.Path, "dist", "*.whl"),
77+
},
78+
}
79+
}
80+
}
81+
8282
if !filepath.IsAbs(artifact.Path) {
8383
artifact.Path = filepath.Join(dirPath, artifact.Path)
8484
}

0 commit comments

Comments
 (0)