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

Example to demonstrate a job picking up a requirements.txt #29

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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 14:48:09 "[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 @@
cowsay
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: 15.1.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!")