-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Python wheels larger than 10MB (#879)
## Changes Previously we only supported uploading Python wheels smaller than 10mb due to using Workspace.Import API and `content ` field https://docs.databricks.com/api/workspace/workspace/import By switching to use `WorkspaceFilesClient` we overcome the limit because it uses POST body for the API instead. ## Tests `TestAccUploadArtifactFileToCorrectRemotePath` integration test passes ``` === RUN TestAccUploadArtifactFileToCorrectRemotePath artifacts_test.go:28: gcp 2023/10/17 15:24:04 INFO Using Google Credentials sdk=true helpers.go:356: Creating /Users/.../integration-test-wsfs-ekggbkcfdkid artifacts.Upload(test.whl): Uploading... 2023/10/17 15:24:06 INFO Using Google Credentials mutator=artifacts.Upload(test) sdk=true artifacts.Upload(test.whl): Upload succeeded helpers.go:362: Removing /Users/.../integration-test-wsfs-ekggbkcfdkid --- PASS: TestAccUploadArtifactFileToCorrectRemotePath (5.66s) PASS coverage: 14.9% of statements in ./... ok github.com/databricks/cli/internal 6.109s coverage: 14.9% of statements in ./... ```
- Loading branch information
1 parent
1b992c0
commit 5273d0c
Showing
3 changed files
with
93 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package bundle | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"path" | ||
"path/filepath" | ||
"regexp" | ||
"testing" | ||
|
||
"github.com/databricks/cli/bundle" | ||
"github.com/databricks/cli/bundle/artifacts" | ||
"github.com/databricks/cli/bundle/config" | ||
"github.com/databricks/cli/internal" | ||
"github.com/databricks/databricks-sdk-go" | ||
"github.com/databricks/databricks-sdk-go/service/compute" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func touchEmptyFile(t *testing.T, path string) { | ||
err := os.MkdirAll(filepath.Dir(path), 0700) | ||
require.NoError(t, err) | ||
f, err := os.Create(path) | ||
require.NoError(t, err) | ||
f.Close() | ||
} | ||
|
||
func TestAccUploadArtifactFileToCorrectRemotePath(t *testing.T) { | ||
t.Log(internal.GetEnvOrSkipTest(t, "CLOUD_ENV")) | ||
|
||
dir := t.TempDir() | ||
whlPath := filepath.Join(dir, "dist", "test.whl") | ||
touchEmptyFile(t, whlPath) | ||
|
||
artifact := &config.Artifact{ | ||
Type: "whl", | ||
Files: []config.ArtifactFile{ | ||
{ | ||
Source: whlPath, | ||
Libraries: []*compute.Library{ | ||
{Whl: "dist\\test.whl"}, | ||
}, | ||
}, | ||
}, | ||
} | ||
|
||
w := databricks.Must(databricks.NewWorkspaceClient()) | ||
wsDir := internal.TemporaryWorkspaceDir(t, w) | ||
|
||
b := &bundle.Bundle{ | ||
Config: config.Root{ | ||
Path: dir, | ||
Bundle: config.Bundle{ | ||
Target: "whatever", | ||
}, | ||
Workspace: config.Workspace{ | ||
ArtifactsPath: wsDir, | ||
}, | ||
Artifacts: config.Artifacts{ | ||
"test": artifact, | ||
}, | ||
}, | ||
} | ||
|
||
err := bundle.Apply(context.Background(), b, artifacts.BasicUpload("test")) | ||
require.NoError(t, err) | ||
require.Regexp(t, regexp.MustCompile(path.Join(wsDir, ".internal/[a-z0-9]+/test.whl")), artifact.Files[0].RemotePath) | ||
require.Regexp(t, regexp.MustCompile(path.Join("/Workspace", wsDir, ".internal/[a-z0-9]+/test.whl")), artifact.Files[0].Libraries[0].Whl) | ||
} |