-
Notifications
You must be signed in to change notification settings - Fork 109
Added support for --bind flag in bundle generate
#3782
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
Changes from all commits
e39477f
184d63a
107af64
7b955ac
ad9f57d
cdb13c4
c7012a2
0fc4929
8fa62af
0872fb0
e09d841
5073592
a744d45
70c693b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| bundle: | ||
| name: auto-bind-test | ||
|
|
||
| workspace: | ||
| root_path: /tmp/${UNIQUE_NAME} | ||
|
|
||
| include: | ||
| - resources/*.yml |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
|
|
||
| === Create a pre-defined job: | ||
| Created job with ID: [NUMID] | ||
|
|
||
| >>> [CLI] workspace mkdirs /Workspace/Users/[USERNAME]/python-[UNIQUE_NAME] | ||
|
|
||
| >>> [CLI] workspace import /Workspace/Users/[USERNAME]/python-[UNIQUE_NAME]/test --file test.py --language PYTHON | ||
|
|
||
| === Generate and bind in one step: | ||
| >>> [CLI] bundle generate job --key test_job --existing-job-id [NUMID] --config-dir resources --source-dir src --bind | ||
| File successfully saved to src/test.py | ||
| Job configuration successfully saved to resources/test_job.job.yml | ||
| Updating deployment state... | ||
| Successfully bound job with an id '[NUMID]' | ||
|
|
||
| >>> ls src/ | ||
| test.py | ||
|
|
||
| >>> cat resources/test_job.job.yml | ||
| name: auto-bind-job-[UNIQUE_NAME] | ||
|
|
||
| === Deploy the bound job: | ||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/tmp/[UNIQUE_NAME]/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
|
|
||
| === Destroy the bundle: | ||
| >>> [CLI] bundle destroy --auto-approve | ||
| The following resources will be deleted: | ||
| delete job test_job | ||
|
|
||
| All files and directories at the following location will be deleted: /Workspace/tmp/[UNIQUE_NAME] | ||
|
|
||
| Deleting files... | ||
| Destroy complete! | ||
|
|
||
| === Check that job is bound and does not exist after bundle is destroyed: | ||
| >>> errcode [CLI] jobs get [NUMID] --output json | ||
| Error: Job [NUMID] does not exist. | ||
|
|
||
| Exit code: 1 | ||
|
|
||
| === Delete the tmp folder: | ||
| >>> [CLI] workspace delete /Workspace/Users/[USERNAME]/python-[UNIQUE_NAME]/test | ||
|
|
||
| >>> [CLI] workspace delete /Workspace/Users/[USERNAME]/python-[UNIQUE_NAME] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| title "Create a pre-defined job:\n" | ||
|
|
||
| PYTHON_NOTEBOOK_DIR="/Workspace/Users/${CURRENT_USER_NAME}/python-${UNIQUE_NAME}" | ||
| PYTHON_NOTEBOOK="${PYTHON_NOTEBOOK_DIR}/test" | ||
|
|
||
| JOB_ID=$($CLI jobs create --json ' | ||
| { | ||
| "name": "auto-bind-job-'${UNIQUE_NAME}'", | ||
| "tasks": [ | ||
| { | ||
| "task_key": "test", | ||
| "new_cluster": { | ||
| "spark_version": "'${DEFAULT_SPARK_VERSION}'", | ||
| "node_type_id": "'${NODE_TYPE_ID}'", | ||
| "num_workers": 1 | ||
| }, | ||
| "notebook_task": { | ||
| "notebook_path": "'${PYTHON_NOTEBOOK}'" | ||
| } | ||
| } | ||
| ] | ||
| }' | jq -r '.job_id') | ||
|
|
||
| echo "Created job with ID: $JOB_ID" | ||
|
|
||
| envsubst < databricks.yml.tmpl > databricks.yml | ||
|
|
||
| cleanup() { | ||
| title "Delete the tmp folder:" | ||
| trace $CLI workspace delete ${PYTHON_NOTEBOOK} | ||
| trace $CLI workspace delete ${PYTHON_NOTEBOOK_DIR} | ||
| } | ||
| trap cleanup EXIT | ||
|
|
||
| trace $CLI workspace mkdirs "${PYTHON_NOTEBOOK_DIR}" | ||
| trace $CLI workspace import "${PYTHON_NOTEBOOK}" --file test.py --language PYTHON | ||
|
|
||
| title "Generate and bind in one step:" | ||
| trace $CLI bundle generate job --key test_job --existing-job-id $JOB_ID --config-dir resources --source-dir src --bind | ||
| trace ls src/ | ||
| # The output of the job is difference per cloud so we only check the name. | ||
| trace cat resources/test_job.job.yml | grep "name: auto-bind-job-${UNIQUE_NAME}" | ||
|
|
||
| title "Deploy the bound job:" | ||
| trace $CLI bundle deploy | ||
|
|
||
| title "Destroy the bundle:" | ||
| trace $CLI bundle destroy --auto-approve | ||
|
|
||
| title "Check that job is bound and does not exist after bundle is destroyed:" | ||
| trace errcode $CLI jobs get "${JOB_ID}" --output json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Databricks notebook source | ||
| print("Test notebook") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # This test is using a workspace import API to load a notebook file. | ||
| # This API has a logic on how to accept notebook files and distinguishes them from regular python files. | ||
| # To succeed locally we would need to replicate this logic in the fake_workspace | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Worth doing some time? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Certainly, there are a bunch of other tests that need this, worth doing this as a separate PR |
||
| Local = false | ||
| Cloud = true | ||
|
|
||
| Ignore = [ | ||
| "databricks.yml", | ||
| "resources/*", | ||
| "src/*", | ||
| ".databricks", | ||
| ] | ||
|
|
||
| [EnvMatrix] | ||
| DATABRICKS_BUNDLE_ENGINE = ["terraform"] | ||
|
|
||
|
|
||
| [Env] | ||
| # MSYS2 automatically converts absolute paths like /Users/$username/$UNIQUE_NAME to | ||
| # C:/Program Files/Git/Users/$username/UNIQUE_NAME before passing it to the CLI | ||
| # Setting this environment variable prevents that conversion on windows. | ||
| MSYS_NO_PATHCONV = "1" | ||
|
|
||
| [[Repls]] | ||
| Old = '\\' | ||
| New = '/' | ||
Uh oh!
There was an error while loading. Please reload this page.