Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions knowledge_base/job_with_requirements_txt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.databricks
34 changes: 34 additions & 0 deletions knowledge_base/job_with_requirements_txt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Job that uses `requirements.txt`

This example demonstrates how to make a job pick up a `requirements.txt` dependency file.

## Prerequisites

* Databricks CLI v0.222.0 (unreleased) 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 job_with_requirements_txt` to run the job.

Example output:

```
$ databricks bundle run job_with_requirements_txt
Run URL: https://...

2024-06-21 13:38:12 "[dev pieter_noordhuis] Example job that uses a requirements.txt file" TERMINATED SUCCESS
_____________
| Hello, world! |
=============
\
\
^__^
(oo)\_______
(__)\ )\/\
||----w |
|| ||
```
13 changes: 13 additions & 0 deletions knowledge_base/job_with_requirements_txt/databricks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bundle:
name: job_with_requirements_txt

include:
- resources/*.yml

workspace:
host: https://myworkspace.cloud.databricks.com

targets:
dev:
default: true
mode: development
1 change: 1 addition & 0 deletions knowledge_base/job_with_requirements_txt/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cowsaw
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
resources:
jobs:
job_with_requirements_txt:
name: Example job that uses a requirements.txt file

tasks:
- task_key: task
job_cluster_key: default
spark_python_task:
python_file: ../src/main.py
libraries:
- requirements: /Workspace/${workspace.file_path}/requirements.txt
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Must be ../requirements.txt.


job_clusters:
- job_cluster_key: default
new_cluster:
spark_version: 14.3.x-scala2.12
node_type_id: i3.xlarge
num_workers: 0
spark_conf:
spark.master: local[*, 4]
spark.databricks.cluster.profile: singleNode
3 changes: 3 additions & 0 deletions knowledge_base/job_with_requirements_txt/src/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from cowsay import cow

cow("Hello, world!")