Skip to content

Commit 353cb5a

Browse files
## Changes Revert "Download spark_python_task workspace files in bundle generate job (databricks#5799)" This reverts commit b2e7e6f. Conflicts: NEXT_CHANGELOG.md ## Why Python files/scripts often include other files, whereas notebooks are more commonly self-contained. With the previous PR, jobs might randomly fail due to missing imports whereas before they would just work.
1 parent de465e0 commit 353cb5a

10 files changed

Lines changed: 3 additions & 147 deletions

File tree

NEXT_CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
### Bundles
1212

13-
* `bundle generate job` now downloads workspace files referenced by `spark_python_task`, rewriting them to a relative path like it already does for notebooks. Git-sourced files and cloud URIs are left untouched ([#5799](https://github.com/databricks/cli/pull/5799)).
1413
* Fix permissions added to a job or pipeline by a Python (PyDABs) mutator failing to deploy with "must have exactly one owner"; the deploying identity is now set as owner, matching resources whose permissions are declared in YAML ([#5821](https://github.com/databricks/cli/pull/5821)).
1514

1615
### Dependency updates

acceptance/bundle/generate/spark_python_task_job/databricks.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

acceptance/bundle/generate/spark_python_task_job/out.job.yml

Lines changed: 0 additions & 11 deletions
This file was deleted.

acceptance/bundle/generate/spark_python_task_job/out.test.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

acceptance/bundle/generate/spark_python_task_job/outjob.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

acceptance/bundle/generate/spark_python_task_job/output.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

acceptance/bundle/generate/spark_python_task_job/script

Lines changed: 0 additions & 1 deletion
This file was deleted.

acceptance/bundle/generate/spark_python_task_job/test.toml

Lines changed: 0 additions & 41 deletions
This file was deleted.

bundle/generate/downloader.go

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,11 @@ type Downloader struct {
3737
}
3838

3939
func (n *Downloader) MarkTaskForDownload(ctx context.Context, task *jobs.Task) error {
40-
if task.NotebookTask != nil {
41-
return n.markNotebookForDownload(ctx, &task.NotebookTask.NotebookPath)
40+
if task.NotebookTask == nil {
41+
return nil
4242
}
4343

44-
if task.SparkPythonTask != nil && isWorkspaceFileTask(task.SparkPythonTask.Source, task.SparkPythonTask.PythonFile) {
45-
return n.markFileForDownload(ctx, &task.SparkPythonTask.PythonFile)
46-
}
47-
48-
return nil
49-
}
50-
51-
// isWorkspaceFileTask reports whether a task file lives in the Databricks
52-
// workspace and should be downloaded. Files sourced from Git (source: GIT) are
53-
// left to the Git repository, and python_file also accepts cloud URIs
54-
// (dbfs:/, s3:/, adls:/, gcs:/) which are not workspace paths; per the Jobs API,
55-
// workspace files are absolute and begin with "/".
56-
func isWorkspaceFileTask(source jobs.Source, filePath string) bool {
57-
return source != jobs.SourceGit && strings.HasPrefix(filePath, "/")
44+
return n.markNotebookForDownload(ctx, &task.NotebookTask.NotebookPath)
5845
}
5946

6047
func (n *Downloader) MarkPipelineLibraryForDownload(ctx context.Context, lib *pipelines.PipelineLibrary) error {
@@ -231,9 +218,6 @@ func (n *Downloader) MarkTasksForDownload(ctx context.Context, tasks []jobs.Task
231218
if task.NotebookTask != nil {
232219
paths = append(paths, task.NotebookTask.NotebookPath)
233220
}
234-
if task.SparkPythonTask != nil && isWorkspaceFileTask(task.SparkPythonTask.Source, task.SparkPythonTask.PythonFile) {
235-
paths = append(paths, task.SparkPythonTask.PythonFile)
236-
}
237221
}
238222
if len(paths) > 0 {
239223
n.basePath = commonDirPrefix(paths)

bundle/generate/downloader_test.go

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -295,72 +295,6 @@ func TestDownloader_MarkTasksForDownload_SingleNotebook(t *testing.T) {
295295
assert.Len(t, downloader.files, 1)
296296
}
297297

298-
func TestDownloader_MarkTasksForDownload_SparkPythonFile(t *testing.T) {
299-
ctx := t.Context()
300-
m := mocks.NewMockWorkspaceClient(t)
301-
302-
dir := "base/dir"
303-
sourceDir := filepath.Join(dir, "source")
304-
configDir := filepath.Join(dir, "config")
305-
downloader := NewDownloader(m.WorkspaceClient, sourceDir, configDir)
306-
307-
pythonFile := "/Users/user/project/etl/job.py"
308-
m.GetMockWorkspaceAPI().EXPECT().GetStatusByPath(ctx, pythonFile).Return(&workspace.ObjectInfo{
309-
Path: pythonFile,
310-
}, nil)
311-
312-
tasks := []jobs.Task{
313-
{
314-
TaskKey: "spark_python_task",
315-
SparkPythonTask: &jobs.SparkPythonTask{
316-
PythonFile: pythonFile,
317-
},
318-
},
319-
}
320-
321-
err := downloader.MarkTasksForDownload(ctx, tasks)
322-
require.NoError(t, err)
323-
324-
assert.Equal(t, "../source/job.py", tasks[0].SparkPythonTask.PythonFile)
325-
require.Len(t, downloader.files, 1)
326-
f := downloader.files[filepath.Join(sourceDir, "job.py")]
327-
assert.Equal(t, pythonFile, f.path)
328-
assert.Equal(t, workspace.ExportFormatSource, f.format)
329-
}
330-
331-
func TestDownloader_MarkTasksForDownload_SparkPythonFileSkipped(t *testing.T) {
332-
ctx := t.Context()
333-
// Cloud URIs and Git-sourced files are not workspace paths, so no
334-
// get-status/download requests should be made for them.
335-
w := newTestWorkspaceClient(t, func(w http.ResponseWriter, r *http.Request) {
336-
t.Fatalf("unexpected request: %s %s", r.Method, r.URL.Path)
337-
})
338-
339-
downloader := NewDownloader(w, "source", "config")
340-
341-
tasks := []jobs.Task{
342-
{
343-
TaskKey: "cloud_uri_task",
344-
SparkPythonTask: &jobs.SparkPythonTask{
345-
PythonFile: "dbfs:/FileStore/job.py",
346-
},
347-
},
348-
{
349-
TaskKey: "git_task",
350-
SparkPythonTask: &jobs.SparkPythonTask{
351-
PythonFile: "etl/job.py",
352-
Source: jobs.SourceGit,
353-
},
354-
},
355-
}
356-
357-
err := downloader.MarkTasksForDownload(ctx, tasks)
358-
require.NoError(t, err)
359-
assert.Empty(t, downloader.files)
360-
assert.Equal(t, "dbfs:/FileStore/job.py", tasks[0].SparkPythonTask.PythonFile)
361-
assert.Equal(t, "etl/job.py", tasks[1].SparkPythonTask.PythonFile)
362-
}
363-
364298
func TestDownloader_MarkTasksForDownload_NoNotebooks(t *testing.T) {
365299
ctx := t.Context()
366300
w := newTestWorkspaceClient(t, func(w http.ResponseWriter, r *http.Request) {

0 commit comments

Comments
 (0)