• Stars
    star
    150
  • Rank 238,550 (Top 5 %)
  • Language
    Scala
  • License
    Apache License 2.0
  • Created about 9 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sbt plugin for Spark packages

sbt-spark-package Build Status

Sbt Plugin for Spark Packages

sbt-spark-package is a Sbt plugin that aims to simplify the use and development of Spark Packages.

Please upgrade to version 0.2.4+ as spark-packages now supports SSL.

Requirements

  • sbt

Setup

The sbt way

Simply add the following to <your_project>/project/plugins.sbt:

  resolvers += "bintray-spark-packages" at "https://dl.bintray.com/spark-packages/maven/"

  addSbtPlugin("org.spark-packages" % "sbt-spark-package" % "0.2.6")

Usage

Spark Package Developers

In your build.sbt file include the appropriate values for:

  • spName := "organization/my-awesome-spark-package" // the name of your Spark Package

Please specify any Spark dependencies using sparkVersion and sparkComponents. For example:

  • sparkVersion := "2.1.0" // the Spark Version your package depends on.

Spark Core will be included by default if no value for sparkComponents is supplied. You can add sparkComponents as:

  • sparkComponents += "mllib" // creates a dependency on spark-mllib.

or

  • sparkComponents ++= Seq("streaming", "sql")

You can make a zip archive ready for a release on the Spark Packages website by simply calling sbt spDist. This command will include any python files related to your package in the jar inside this archive. When this jar is added to your PYTHONPATH, you will be able to use your Python files.

By default, the zip file will be produced in <project>/target, but you can override this by providing a value for spDistDirectory like:

spDistDirectory := "Users" / "foo" / "Documents" / "bar"

The slashes should still remain as slashes on a Windows system, don't switch them to backslashes.

You may publish your package locally for testing with sbt spPublishLocal.

In addition, sbt console will create you a Spark Context for testing your code like the spark-shell.

If you want to make a release of your package against multiple Scala versions (e.g. 2.10, 2.11), you may set spAppendScalaVersion := true in your build file.

In any case where you really can't specify Spark dependencies using sparkComponents (e.g. you have exclusion rules) and configure them as provided (e.g. standalone jar for a demo), you may use spIgnoreProvided := true to properly use the assembly plugin.

Including shaded dependencies

Sometimes you may require shading for your package to work in certain environments. sbt-spark-package supports publishing shaded dependencies built through the sbt-assembly plugin. To achieve this, you will need two projects, one for building the shaded dependency, and one for building the distribution ready package.

lazy val shaded = Project("shaded", file(".")).settings(
  libraryDependencies ++= (dependenciesToShade ++
    nonShadedDependencies.map(_ % "provided")), // don't include any other dependency in your assembly jar
  target := target.value / "shaded", // have a separate target directory to make sbt happy
  assemblyShadeRules in assembly := Seq(
    ShadeRule.rename("blah.**" -> "bleh.@1").inAll
  )
) // add all other settings

lazy val distribute = Project("distribution", file(".")).settings(
  spName := ... // your spark package name
  target := target.value / "distribution",
  spShade := true, // THIS IS THE MOST IMPORTANT SETTING
  assembly in spPackage := (assembly in shaded).value, // this will pick up the shaded jar for distribution
  libraryDependencies := nonShadedDependencies // have all your non shaded dependencies here so that we can
                                               // generate a clean pom.
) // add all other settings

Now you may use distribution/spDist to build your zip file, or distribution/spPublish to publish a new release. For more details on publishing, please refer to the next section.

Registering and publishing Spark Packages

credentials

In order to use spRegister or spPublish to register or publish a release of your Spark Package, you have to specify your Github credentials. You may specify your credentials through a file (recommended) or directly in your build file like below:

credentials += Credentials(Path.userHome / ".ivy2" / ".sbtcredentials") // A file containing credentials

credentials += Credentials("Spark Packages Realm",
                           "spark-packages.org",
                           s"$GITHUB_USERNAME",
                           s"GITHUB_PERSONAL_ACCESS_TOKEN")

More can be found in the sbt documentation.

Using these functions require "read:org" Github access to authenticate ownership of the repo. Documentation to generate a Github Personal Access Token can be found here.

spRegister

You can register your Spark Package for the first time using this plugin with the command sbt spRegister. In order to register your package, you must have logged in to the Spark Packages website at least once and supply values for the following settings in your build file:

spShortDescription := "My awesome Spark Package" // Your one line description of your package

spDescription := """My long description.
                    |Could be multiple lines long.
                    | - My package can do this,
                    | - My package can do that.""".stripMargin

credentials += // Your credentials, see above.

The homepage of your package is by default the web page for the Github repository. You can change the default homepage by using:

spHomepage := // Set this if you want to specify a web page other than your github repository.

spPublish

You can publish a new release using sbt spPublish. The HEAD commit on your local repository will be used as the git commit sha for your release. Therefore, please make sure that your local commit is indeed the version you would like to make a release for, and that you have pushed that commit to the master branch on your remote.

The required settings for spPublish are:

// You must have an Open Source License. Some common licenses can be found in: http://opensource.org/licenses
licenses += "Apache-2.0" -> url("http://opensource.org/licenses/Apache-2.0")

// If you published your package to Maven Central for this release (must be done prior to spPublish)
spIncludeMaven := true

credentials += // Your credentials, see above.

Spark Package Users

Any Spark Packages your package depends on can be added as:

  • spDependencies += "databricks/spark-avro:0.1" // format is spark-package-name:version

We also recommend that you use sparkVersion and sparkComponents to manage your Spark dependencies. In addition, you can use sbt assembly to create an uber jar of your project.

Contributions

If you encounter bugs or want to contribute, feel free to submit an issue or pull request.

More Repositories

1

learning-spark

Example code from Learning Spark book
Java
3,864
star
2

koalas

Koalas: pandas API on Apache Spark
Python
3,317
star
3

Spark-The-Definitive-Guide

Spark: The Definitive Guide's Code Repository
Scala
2,678
star
4

scala-style-guide

Databricks Scala Coding Style Guide
2,673
star
5

spark-deep-learning

Deep Learning Pipelines for Apache Spark
Python
1,984
star
6

click

The "Command Line Interactive Controller for Kubernetes"
Rust
1,416
star
7

LearningSparkV2

This is the github repo for Learning Spark: Lightning-Fast Data Analytics [2nd Edition]
Scala
1,077
star
8

spark-sklearn

(Deprecated) Scikit-learn integration package for Apache Spark
Python
1,076
star
9

spark-csv

CSV Data Source for Apache Spark 1.x
Scala
1,051
star
10

tensorframes

[DEPRECATED] Tensorflow wrapper for DataFrames on Apache Spark
Scala
751
star
11

devrel

This repository contains the notebooks and presentations we use for our Databricks Tech Talks
HTML
672
star
12

reference-apps

Spark reference applications
Scala
648
star
13

spark-redshift

Redshift data source for Apache Spark
Scala
598
star
14

spark-sql-perf

Scala
543
star
15

spark-avro

Avro Data Source for Apache Spark
Scala
538
star
16

spark-xml

XML data source for Spark SQL and DataFrames
Scala
481
star
17

spark-corenlp

Stanford CoreNLP wrapper for Apache Spark
Scala
424
star
18

spark-training

Apache Spark training material
Scala
396
star
19

databricks-cli

(Legacy) Command Line Interface for Databricks
Python
376
star
20

spark-perf

Performance tests for Apache Spark
Scala
372
star
21

terraform-provider-databricks

Databricks Terraform Provider
Go
333
star
22

spark-knowledgebase

Spark Knowledge Base
328
star
23

delta-live-tables-notebooks

Python
296
star
24

databricks-ml-examples

Python
284
star
25

sjsonnet

Scala
252
star
26

mlops-stacks

This repo provides a customizable stack for starting new ML projects on Databricks that follow production best-practices out of the box.
Python
243
star
27

jsonnet-style-guide

Databricks Jsonnet Coding Style Guide
205
star
28

databricks-sdk-py

Databricks SDK for Python (Beta)
Python
185
star
29

dbt-databricks

A dbt adapter for Databricks.
Python
179
star
30

containers

Sample base images for Databricks Container Services
Dockerfile
157
star
31

databricks-sql-python

Databricks SQL Connector for Python
Python
125
star
32

benchmarks

A place in which we publish scripts for reproducible benchmarks.
Python
106
star
33

databricks-vscode

VS Code extension for Databricks
TypeScript
104
star
34

terraform-databricks-examples

Examples of using Terraform to deploy Databricks resources
HCL
103
star
35

notebook-best-practices

An example showing how to apply software engineering best practices to Databricks notebooks.
Python
102
star
36

spark-tfocs

A Spark port of TFOCS: Templates for First-Order Conic Solvers (cvxr.com/tfocs)
Scala
88
star
37

intellij-jsonnet

Intellij Jsonnet Plugin
Java
82
star
38

sbt-databricks

An sbt plugin for deploying code to Databricks Cloud
Scala
71
star
39

spark-integration-tests

Integration tests for Spark
Scala
68
star
40

terraform-databricks-lakehouse-blueprints

Set of Terraform automation templates and quickstart demos to jumpstart the design of a Lakehouse on Databricks. This project has incorporated best practices across the industries we work with to deliver composable modules to build a workspace to comply with the highest platform security and governance standards.
Python
61
star
41

spark-pr-dashboard

Dashboard to aid in Spark pull request reviews
JavaScript
54
star
42

run-notebook

TypeScript
44
star
43

simr

Spark In MapReduce (SIMR) - launching Spark applications on existing Hadoop MapReduce infrastructure
Java
44
star
44

ide-best-practices

Best practices for working with Databricks from an IDE
Python
40
star
45

devbox

Scala
37
star
46

unity-catalog-setup

Notebooks, terraform, tools to enable setting up Unity Catalog
37
star
47

diviner

Grouped time series forecasting engine
Python
33
star
48

cli

Databricks CLI
Go
32
star
49

security-bucket-brigade

JavaScript
30
star
50

databricks-sdk-go

Databricks SDK for Go
Go
29
star
51

pig-on-spark

proof-of-concept implementation of Pig-on-Spark integrated at the logical node level
Scala
28
star
52

databricks-sql-cli

CLI for querying Databricks SQL
Python
27
star
53

automl

Python
26
star
54

databricks-sql-go

Golang database/sql driver for Databricks SQL.
Go
24
star
55

tpch-dbgen

Patched version of dbgen
C
22
star
56

als-benchmark-scripts

Scripts to benchmark distributed Alternative Least Squares (ALS)
Scala
22
star
57

databricks-sql-nodejs

Databricks SQL Connector for Node.js
JavaScript
21
star
58

spark-package-cmd-tool

A command line tool for Spark packages
Python
18
star
59

python-interview

Databricks Python interview setup instructions
15
star
60

xgb-regressor

MLflow XGBoost Regressor
Python
15
star
61

databricks-accelerators

Accelerate the use of Databricks for customers [public repo]
Python
15
star
62

tableau-connector

Scala
12
star
63

files_in_repos

Python
12
star
64

upload-dbfs-temp

TypeScript
12
star
65

spark-sklearn-docs

HTML
11
star
66

genomics-pipelines

secondary analysis pipelines parallelized with apache spark
Scala
10
star
67

workflows-examples

10
star
68

databricks-sdk-java

Databricks SDK for Java
Java
10
star
69

sqltools-databricks-driver

SQLTools driver for Databricks SQL
TypeScript
9
star
70

xgboost-linux64

Databricks Private xgboost Linux64 fork
C++
8
star
71

tmm

Python
7
star
72

mlflow-example-sklearn-elasticnet-wine

Jupyter Notebook
7
star
73

databricks-ttyd

C
6
star
74

dais-cow-bff

Code for the "Bridging the Production Gap" DAIS 2023 talk
Jupyter Notebook
4
star
75

setup-cli

Sets up the Databricks CLI in your GitHub Actions workflow.
Shell
4
star
76

terraform-databricks-mlops-aws-project

This module creates and configures service principals with appropriate permissions and entitlements to run CI/CD for a project, and creates a workspace directory as a container for project-specific resources for the Databricks AWS staging and prod workspaces.
HCL
4
star
77

jenkins-job-builder

Fork of https://docs.openstack.org/infra/jenkins-job-builder/ to include unmerged patches
Python
4
star
78

terraform-databricks-mlops-azure-project-with-sp-creation

This module creates and configures service principals with appropriate permissions and entitlements to run CI/CD for a project, and creates a workspace directory as a container for project-specific resources for the Azure Databricks staging and prod workspaces. It also creates the relevant Azure Active Directory (AAD) applications for the service principals.
HCL
4
star
79

terraform-databricks-sra

The Security Reference Architecture (SRA) implements typical security features as Terraform Templates that are deployed by most high-security organizations, and enforces controls for the largest risks that customers ask about most often.
HCL
4
star
80

databricks-empty-ide-project

Empty IDE project used by the VSCode extension for Databricks
3
star
81

databricks-repos-proxy

Python
2
star
82

databricks-asset-bundles-dais2023

Python
2
star
83

pex

Fork of pantsbuild/pex with a few Databricks-specific changes
Python
2
star
84

SnpEff

Databricks snpeff fork
Java
2
star
85

databricks-dbutils-scala

The Scala SDK for Databricks.
Scala
2
star
86

notebook_gallery

Jupyter Notebook
2
star
87

terraform-databricks-mlops-aws-infrastructure

This module sets up multi-workspace model registry between a Databricks AWS development (dev) workspace, staging workspace, and production (prod) workspace, allowing READ access from dev/staging workspaces to staging & prod model registries.
HCL
2
star
88

homebrew-tap

Homebrew Tap for the Databricks CLI
Ruby
1
star
89

terraform-databricks-mlops-azure-infrastructure-with-sp-creation

This module sets up multi-workspace model registry between an Azure Databricks development (dev) workspace, staging workspace, and production (prod) workspace, allowing READ access from dev/staging workspaces to staging & prod model registries. It also creates the relevant Azure Active Directory (AAD) applications for the service principals.
HCL
1
star
90

mfg_dlt_workshop

DLT Manufacturing Workshop
Python
1
star
91

terraform-databricks-mlops-azure-project-with-sp-linking

This module creates and configures service principals with appropriate permissions and entitlements to run CI/CD for a project, and creates a workspace directory as a container for project-specific resources for the Azure Databricks staging and prod workspaces. It also links pre-existing Azure Active Directory (AAD) applications to the service principals.
HCL
1
star
92

terraform-databricks-mlops-azure-infrastructure-with-sp-linking

This module sets up multi-workspace model registry between an Azure Databricks development (dev) workspace, staging workspace, and production (prod) workspace, allowing READ access from dev/staging workspaces to staging & prod model registries. It also links pre-existing Azure Active Directory (AAD) applications to the service principals.
HCL
1
star