-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from ministryofjustice/ag--fix-spark-s3-access…
…-problems allspark: Updated Spark dependencies (PYSPARK_SUBMIT_ARGS)
- Loading branch information
Showing
4 changed files
with
32 additions
and
9 deletions.
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
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 |
---|---|---|
@@ -1,13 +1,7 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
os.environ['PYSPARK_SUBMIT_ARGS'] = '--packages com.amazonaws:aws-java-sdk:1.7.4,org.apache.hadoop:hadoop-aws:2.7.1 pyspark-shell' | ||
|
||
import pyspark | ||
sc = pyspark.SparkContext("local[*]") | ||
|
||
from pyspark.sql import SQLContext | ||
sqlContext = SQLContext(sc) | ||
|
||
hadoopConf = sc._jsc.hadoopConfiguration() | ||
hadoopConf.set("fs.s3a.impl", "org.apache.hadoop.fs.s3a.S3AFileSystem") |
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,22 @@ | ||
title 'Working pyspark' | ||
|
||
control "pyspark is available" do | ||
impact "high" | ||
title "pyspark should be installed and work" | ||
desc "pyspark installed and can run pyspark jobs" | ||
tag "pyspark" | ||
tag "spark" | ||
|
||
describe command("echo $SPARK_HOME") do | ||
its("stdout.strip") { should eq "/usr/local/spark" } | ||
end | ||
|
||
# Can run on of the spark examples | ||
describe command("python3 /usr/local/spark/examples/src/main/python/pi.py") do | ||
its("exit_status") { should eq 0 } | ||
# Pi calculated using Spark example job is very | ||
# approximate, once it returned 3.13### | ||
# so checking against 3.1 to avoid random failures | ||
its("stdout") { should match /Pi is roughly 3.1/ } | ||
end | ||
end |
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 |
---|---|---|
@@ -1,3 +1,8 @@ | ||
from pyspark.context import SparkContext | ||
from pyspark.sql import SparkSession | ||
|
||
sc = SparkContext.getOrCreate() | ||
spark = SparkSession(sc) | ||
|
||
spark.read_parquet() | ||
df = spark.read.csv("s3a://bucket/path/to/file.csv") | ||
df.limit(10).show() |