|
| 1 | +import scala.sys.process.Process |
| 2 | + |
| 3 | +enablePlugins(SparkPackagePlugin, AssemblyPlugin) |
| 4 | + |
| 5 | +val pysparkCmd = taskKey[Unit]("Builds pyspark package and emits command string for running pyspark with package") |
| 6 | + |
| 7 | +lazy val pyTest = taskKey[Unit]("Run pyrasterframes tests.") |
| 8 | + |
| 9 | +lazy val pyExamples = taskKey[Unit]("Run pyrasterframes examples.") |
| 10 | + |
| 11 | +lazy val pyEgg = taskKey[Unit]("Creates a Python .egg file") |
| 12 | + |
| 13 | +lazy val spJarFile = Def.taskDyn { |
| 14 | + if (spShade.value) { |
| 15 | + Def.task((assembly in spPackage).value) |
| 16 | + } else { |
| 17 | + Def.task(spPackage.value) |
| 18 | + } |
| 19 | +} |
| 20 | + |
| 21 | +spName := "io.astraea/pyrasterframes" |
| 22 | +sparkVersion := rfSparkVersion.value |
| 23 | +sparkComponents ++= Seq("sql", "mllib") |
| 24 | +spAppendScalaVersion := false |
| 25 | +spIncludeMaven := false |
| 26 | +spIgnoreProvided := true |
| 27 | +spShade := true |
| 28 | +spPackage := { |
| 29 | + val dist = spDist.value |
| 30 | + val extracted = IO.unzip(dist, (target in spPackage).value, GlobFilter("*.jar")) |
| 31 | + if(extracted.size != 1) sys.error("Didn't expect to find multiple .jar files in distribution.") |
| 32 | + extracted.head |
| 33 | +} |
| 34 | +spShortDescription := description.value |
| 35 | +spHomepage := homepage.value.get.toString |
| 36 | +spDescription := """ |
| 37 | + |RasterFrames brings the power of Spark DataFrames to geospatial raster data, |
| 38 | + |empowered by the map algebra and tile layer operations of GeoTrellis. |
| 39 | + | |
| 40 | + |The underlying purpose of RasterFrames is to allow data scientists and software |
| 41 | + |developers to process and analyze geospatial-temporal raster data with the |
| 42 | + |same flexibility and ease as any other Spark Catalyst data type. At its core |
| 43 | + |is a user-defined type (UDT) called TileUDT, which encodes a GeoTrellis Tile |
| 44 | + |in a form the Spark Catalyst engine can process. Furthermore, we extend the |
| 45 | + |definition of a DataFrame to encompass some additional invariants, allowing |
| 46 | + |for geospatial operations within and between RasterFrames to occur, while |
| 47 | + |still maintaining necessary geo-referencing constructs. |
| 48 | + """.stripMargin |
| 49 | + |
| 50 | +test in assembly := {} |
| 51 | + |
| 52 | +spPublishLocal := { |
| 53 | + // This unfortunate override is necessary because |
| 54 | + // the ivy resolver in pyspark defaults to the cache more |
| 55 | + // frequently than we'd like. |
| 56 | + val id = (projectID in spPublishLocal).value |
| 57 | + val home = ivyPaths.value.ivyHome |
| 58 | + .getOrElse(io.Path.userHome / ".ivy2") |
| 59 | + val cacheDir = home / "cache" / id.organization / id.name |
| 60 | + IO.delete(cacheDir) |
| 61 | + spPublishLocal.value |
| 62 | +} |
| 63 | + |
| 64 | +pysparkCmd := { |
| 65 | + val _ = spPublishLocal.value |
| 66 | + val id = (projectID in spPublishLocal).value |
| 67 | + val args = "pyspark" :: "--packages" :: s"${id.organization}:${id.name}:${id.revision}" :: Nil |
| 68 | + streams.value.log.info("PySpark Command:\n" + args.mkString(" ")) |
| 69 | + // --conf spark.jars.ivy=(ivyPaths in pysparkCmd).value.... |
| 70 | +} |
| 71 | + |
| 72 | +ivyPaths in pysparkCmd := ivyPaths.value.withIvyHome(target.value / "ivy") |
| 73 | + |
| 74 | +//credentials += Credentials(Path.userHome / ".ivy2" / ".credentials") |
| 75 | + |
| 76 | +pyTest := { |
| 77 | + val _ = spPublishLocal.value |
| 78 | + val s = streams.value |
| 79 | + val wd = baseDirectory.value / "python" |
| 80 | + Process("python setup.py test", wd) ! s.log |
| 81 | +} |
| 82 | + |
| 83 | +Test / test := (Test / test).dependsOn(pyTest).value |
| 84 | + |
| 85 | +pyEgg := { |
| 86 | + val s = streams.value |
| 87 | + val wd = baseDirectory.value / "python" |
| 88 | + Process("python setup.py bdist_egg", wd) ! s.log |
| 89 | +} |
| 90 | + |
| 91 | +pyExamples := { |
| 92 | + val _ = spPublishLocal.value |
| 93 | + val s = streams.value |
| 94 | + val wd = baseDirectory.value / "python" |
| 95 | + Process("python setup.py examples", wd) ! s.log |
| 96 | +} |
| 97 | + |
0 commit comments