-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add example for a job writing to a Unity Catalog volume #51
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5176b56
Add example for a job writing to a UC Volume
shreyas-goenka c4bc362
-
shreyas-goenka b35c803
-
shreyas-goenka 84c6a47
-
shreyas-goenka 3f6edb5
-
shreyas-goenka 0715a02
-
shreyas-goenka ff31515
-
shreyas-goenka 3e83f88
-
shreyas-goenka 82624d4
-
shreyas-goenka a099678
address comments
shreyas-goenka 3f93da6
address comments
shreyas-goenka e4d9576
Add trailing newline
shreyas-goenka f98a0c3
-
shreyas-goenka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.databricks/ |
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,20 @@ | ||
# Save job result to volume | ||
|
||
This example demonstrates how to define and use a Unity Catalog Volume in a Databricks Asset Bundle. | ||
|
||
Specifically we'll define a `hello_world_job` job which writes "Hello, World!" | ||
to a file in a Unity Catalog Volume. | ||
|
||
The bundle also defines a Volume and the associated Schema in which the Job writes text to. | ||
|
||
## Prerequisites | ||
|
||
* Databricks CLI v0.236.0 or above | ||
|
||
## Usage | ||
|
||
Update the `host` field under `workspace` in `databricks.yml` to the Databricks workspace you wish to deploy to. | ||
|
||
Run `databricks bundle deploy` to deploy the job. | ||
|
||
Run `databricks bundle run hello_world_job` to run the job and store the results in UC volume. |
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,12 @@ | ||
bundle: | ||
name: write_from_job_to_volume | ||
|
||
include: | ||
- resources/*.yml | ||
|
||
workspace: | ||
host: https://e2-dogfood.staging.cloud.databricks.com | ||
|
||
targets: | ||
dev: | ||
default: true |
16 changes: 16 additions & 0 deletions
16
knowledge_base/write_from_job_to_volume/resources/hello_world.job.yml
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,16 @@ | ||
resources: | ||
jobs: | ||
hello_world_job: | ||
name: hello_world_job | ||
|
||
# No job cluster is configured. The job will run on serverless compute. | ||
# You can explicitly configure job compute here if your workspace does | ||
# not have serverless compute enabled. | ||
tasks: | ||
- task_key: hello_world_job_task | ||
notebook_task: | ||
notebook_path: ../src/hello.ipynb | ||
|
||
parameters: | ||
- name: file_path | ||
default: /Volumes/main/${resources.schemas.hello_world_schema.name}/${resources.volumes.my_volume.name}/hello_world.txt |
5 changes: 5 additions & 0 deletions
5
knowledge_base/write_from_job_to_volume/resources/hello_world.schema.yml
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,5 @@ | ||
resources: | ||
schemas: | ||
hello_world_schema: | ||
catalog_name: main | ||
name: ${workspace.current_user.short_name}_hello_world |
9 changes: 9 additions & 0 deletions
9
knowledge_base/write_from_job_to_volume/resources/my_volume.volume.yml
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,9 @@ | ||
resources: | ||
volumes: | ||
my_volume: | ||
catalog_name: main | ||
# We use the ${resources.schemas...} interpolation syntax to force the creation | ||
# of the schema before the volume. Usage of the ${resources.schemas...} syntax | ||
# allows Databricks Asset Bundles to form a dependency graph between resources. | ||
schema_name: ${resources.schemas.hello_world_schema.name} | ||
name: my_volume |
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,21 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"file_path = dbutils.widgets.get(\"file_path\")\n", | ||
"dbutils.fs.put(file_path, \"Hello World!\", overwrite=True)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't actually work does it? Without a
dbutils.widgets.text()
and/orwidgets
section in the ipynb JSON belowThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works fine: