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

Support passing job parameters to bundle run #1115

Merged
merged 2 commits into from
Jan 15, 2024
Merged

Support passing job parameters to bundle run #1115

merged 2 commits into from
Jan 15, 2024

Conversation

pietern
Copy link
Contributor

@pietern pietern commented Jan 11, 2024

Changes

This change adds support for job parameters. If job parameters are specified for a job that doesn't define job parameters it returns an error. Conversely, if task parameters are specified for a job that defines job parameters, it also returns an error.

This change moves the options structs and their functions to separate files and backfills test coverage for them.

Job parameters can now be specified with --params foo=bar,bar=qux.

Tests

Unit tests and manual integration testing.

This change adds support for job parameters. If job parameters are specified
for a job that doesn't define job parameters it returns an error. Conversely,
if task parameters are specified for a job that defines job parameters, it also
returns an error.

This changes moves the options structs and their functions to separate files
and backfills test coverage for them.

Job parameters can now be specified with `--param foo=bar,bar=qux`.
@codecov-commenter
Copy link

codecov-commenter commented Jan 11, 2024

Codecov Report

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

Comparison is base (3c76a11) 49.08% compared to head (0b22965) 49.52%.
Report is 4 commits behind head on main.

Files Patch % Lines
bundle/run/job_options.go 43.63% 30 Missing and 1 partial ⚠️
bundle/run/pipeline_options.go 66.66% 8 Missing ⚠️
bundle/run/job.go 0.00% 1 Missing ⚠️
bundle/run/pipeline.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1115      +/-   ##
==========================================
+ Coverage   49.08%   49.52%   +0.44%     
==========================================
  Files         270      275       +5     
  Lines       10556    10591      +35     
==========================================
+ Hits         5181     5245      +64     
+ Misses       4821     4790      -31     
- Partials      554      556       +2     

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

fs.StringToStringVar(&o.sqlParams, "sql-params", nil, "A map from keys to values for jobs with SQL tasks.")

// Define job parameters flag.
fs.StringToStringVar(&o.jobParams, "params", nil, "comma separated k=v pairs for job parameters")
Copy link
Contributor

Choose a reason for hiding this comment

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

What does this look like in the help output?

For e.g. notebook params, stringToString looks pretty weird:

--notebook-params stringToString       A map from keys to values for jobs with notebook tasks. (default [])

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks the same. We should address this in a separate change (I copied most of the code from job.go).

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good.

return fmt.Errorf("job not defined")
}

// Ensure mutual exclusion on job parameters and task parameters.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

}

func (o *PipelineOptions) Define(fs *flag.FlagSet) {
fs.BoolVar(&o.RefreshAll, "refresh-all", false, "Perform a full graph update.")
Copy link
Contributor

Choose a reason for hiding this comment

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

The name of flags are very unintuitive but I guess they are just in line with API naming?

Copy link
Contributor Author

@pietern pietern Jan 15, 2024

Choose a reason for hiding this comment

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

Indeed. Aside from API, this is also in line with how these are named in the web UI.

@pietern pietern added this pull request to the merge queue Jan 15, 2024
Merged via the queue into main with commit 06b5067 Jan 15, 2024
4 checks passed
@pietern pietern deleted the run-job-params branch January 15, 2024 07:47
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.

feat: support job parameters within databricks bundle run
4 participants