Skip to content
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

Added databricks bundle generate job command #1043

Merged
merged 15 commits into from
Jan 17, 2024
Merged

Conversation

andrewnester
Copy link
Contributor

@andrewnester andrewnester commented Dec 6, 2023

Changes

Now it's possible to generate bundle configuration for existing job.
For now it only supports jobs with notebook tasks.

It will download notebooks referenced in the job tasks and generate bundle YAML config for this job which can be included in larger bundle.

Tests

Running command manually

Example of generated config

resources:
  jobs:
    job_128737545467921:
      name: Notebook job
      format: MULTI_TASK
      tasks:
        - task_key: as_notebook
          existing_cluster_id: 0704-xxxxxx-yyyyyyy
          notebook_task:
            base_parameters:
              bundle_root: /Users/andrew.nester@databricks.com/.bundle/job_with_module_imports/development/files
            notebook_path: ./entry_notebook.py
            source: WORKSPACE
          run_if: ALL_SUCCESS
      max_concurrent_runs: 1

Tests

Manual (on our last 100 jobs) + added end-to-end test

--- PASS: TestAccGenerateFromExistingJobAndDeploy (50.91s)
PASS
coverage: 61.5% of statements in ./...
ok      github.com/databricks/cli/internal/bundle       51.209s coverage: 61.5% of statements in ./...

@andrewnester andrewnester changed the title Added databricks bundle generate job command Added databricks bundle generate job command Dec 6, 2023
cmd/bundle/generate/job.go Outdated Show resolved Hide resolved
cmd/bundle/generate/job.go Outdated Show resolved Hide resolved
}

for _, task := range job.Settings.Tasks {
err := downloadNotebookAndReplaceTaskPath(ctx, &task, w, outputDir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also do this for SparkPythonTask. Are we also planning to do this for wheel and jar tasks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shreyas-goenka eventually yes, for now it's only scoped to notebook tasks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we can't really fully support wheel and jar tasks without user intervention, since we'd want the Python/Scala sources, not the wheel or jar file. The job doesn't know about those sources.

libs/config/value.go Outdated Show resolved Hide resolved
// See convert.convertMap for details
sort.SliceStable(keys, func(i, j int) bool {
return m[keys[i]].Location().Line < m[keys[j]].Location().Line
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart :)

libs/convert/job.go Outdated Show resolved Hide resolved
libs/convert/utils.go Outdated Show resolved Hide resolved
cmd/bundle/generate/job.go Outdated Show resolved Hide resolved
cmd/bundle/bundle.go Show resolved Hide resolved
cmd/bundle/generate/job.go Outdated Show resolved Hide resolved
nfx
nfx previously requested changes Dec 13, 2023
cmd/bundle/generate/utils_test.go Outdated Show resolved Hide resolved
cmd/bundle/generate/utils.go Show resolved Hide resolved
cmd/bundle/generate/utils.go Show resolved Hide resolved
cmd/bundle/generate/utils_test.go Outdated Show resolved Hide resolved
libs/convert/job.go Outdated Show resolved Hide resolved
libs/convert/utils.go Outdated Show resolved Hide resolved
libs/convert/utils.go Outdated Show resolved Hide resolved
libs/convert/job.go Outdated Show resolved Hide resolved
@codecov-commenter
Copy link

codecov-commenter commented Jan 14, 2024

Codecov Report

Attention: 62 lines in your changes are missing coverage. Please review.

Comparison is base (2c0d067) 49.24% compared to head (63466bd) 49.50%.
Report is 3 commits behind head on main.

Files Patch % Lines
libs/dyn/yamlsaver/saver.go 59.21% 28 Missing and 3 partials ⚠️
libs/notebook/ext.go 0.00% 13 Missing ⚠️
libs/dyn/yamlsaver/utils.go 33.33% 5 Missing and 5 partials ⚠️
cmd/bundle/generate.go 0.00% 6 Missing ⚠️
cmd/bundle/bundle.go 0.00% 1 Missing ⚠️
libs/dyn/value.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1043      +/-   ##
==========================================
+ Coverage   49.24%   49.50%   +0.26%     
==========================================
  Files         273      281       +8     
  Lines       10570    10711     +141     
==========================================
+ Hits         5205     5303      +98     
- Misses       4810     4844      +34     
- Partials      555      564       +9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we have the YAML loader in a separate package, I think the YAML saver should also be outside of the main dyn package. The attributes we need to turn a dyn.Value tree into a YAML document are all public/exported anyway.

bundle/config/generate/job.go Outdated Show resolved Hide resolved
bundle/config/generate/job.go Outdated Show resolved Hide resolved
cmd/bundle/generate/job.go Outdated Show resolved Hide resolved
cmd/bundle/generate/utils.go Outdated Show resolved Hide resolved
cmd/bundle/generate/utils.go Show resolved Hide resolved
libs/dyn/convert/utils.go Outdated Show resolved Hide resolved
libs/dyn/convert/utils.go Outdated Show resolved Hide resolved
libs/dyn/key.go Outdated Show resolved Hide resolved
libs/dyn/convert/utils.go Outdated Show resolved Hide resolved
libs/dyn/value.go Outdated Show resolved Hide resolved
bundle/config/generate/job.go Outdated Show resolved Hide resolved
cmd/bundle/generate/job.go Outdated Show resolved Hide resolved
cmd/bundle/generate/utils.go Outdated Show resolved Hide resolved
cmd/bundle/generate/utils.go Show resolved Hide resolved
cmd/bundle/generate/utils.go Outdated Show resolved Hide resolved
libs/dyn/value.go Show resolved Hide resolved
libs/dyn/value.go Outdated Show resolved Hide resolved
libs/dyn/yamlsaver/utils.go Show resolved Hide resolved
Copy link
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two minor remaining issues. Unblocking merge.

cmd/bundle/generate/job.go Outdated Show resolved Hide resolved
libs/dyn/value.go Outdated Show resolved Hide resolved
libs/textutil/textutil.go Outdated Show resolved Hide resolved
@andrewnester andrewnester dismissed nfx’s stale review January 17, 2024 14:26

already addressed

@andrewnester andrewnester added this pull request to the merge queue Jan 17, 2024
Merged via the queue into main with commit 70fe0e3 Jan 17, 2024
4 checks passed
@andrewnester andrewnester deleted the generate-yaml-notebook branch January 17, 2024 14:31
andrewnester added a commit that referenced this pull request Jan 17, 2024
CLI:
 * Fix windows style file paths in fs cp command ([#1118](#1118)).
 * Do not require positional arguments if they should be provided in JSON ([#1125](#1125)).
 * Always require path parameters as positional arguments ([#1129](#1129)).

Bundles:
 * Add debug log line for when bundle init is run from non-TTY interface ([#1117](#1117)).
 * Added `databricks bundle generate job` command ([#1043](#1043)).
 * Support passing job parameters to bundle run ([#1115](#1115)).

Dependency updates:
 * Bump golang.org/x/oauth2 from 0.15.0 to 0.16.0 ([#1124](#1124)).
@andrewnester andrewnester mentioned this pull request Jan 17, 2024
github-merge-queue bot pushed a commit that referenced this pull request Jan 17, 2024
CLI:
* Fix windows style file paths in fs cp command
([#1118](#1118)).
* Do not require positional arguments if they should be provided in JSON
([#1125](#1125)).
* Always require path parameters as positional arguments
([#1129](#1129)).

Bundles:
* Add debug log line for when bundle init is run from non-TTY interface
([#1117](#1117)).
* Added `databricks bundle generate job` command
([#1043](#1043)).
* Support passing job parameters to bundle run
([#1115](#1115)).

Dependency updates:
* Bump golang.org/x/oauth2 from 0.15.0 to 0.16.0
([#1124](#1124)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants