Skip to content

Instantly share code, notes, and snippets.

@metasim
Created November 11, 2018 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metasim/c4d1225124fcf53cac2d04330ee3f411 to your computer and use it in GitHub Desktop.
Save metasim/c4d1225124fcf53cac2d04330ee3f411 to your computer and use it in GitHub Desktop.
Test files for loading a saved model using RasterFrames
# Tested with Spark 2.2.1, Python 3.6.4
# Even though we've used `--py-files` on the command line,
# unintuitively this still seems necessary to import pyrasterframes
SparkContext.addPyFile(spark.sparkContext, 'pyrasterframes.zip')
from pyrasterframes import *
spark.withRasterFrames()
from pyspark.ml import PipelineModel
model_load = PipelineModel.load("test_model")
#!/bin/bash
if [ ! -d test_model ]; then
echo "Please unzip test_model.zip here."
exit 1
elif [ ! read-model.py ]; then
echo "Please save read-model.py script here."
exit 2
fi
if [ ! -f pyrasterframes.zip ]; then
curl --output pyrasterframes.zip https://repo1.maven.org/maven2/org/locationtech/rasterframes/pyrasterframes_2.11/0.7.1/pyrasterframes_2.11-0.7.1-python.zip
fi
export PYTHONSTARTUP=read-model.py
pyspark --master 'local[*]' \
--conf spark.sql.catalogImplementation=in-memory \
--py-files pyrasterframes.zip \
--packages org.locationtech.rasterframes:pyrasterframes_2.11:0.7.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment