Skip to content

Commit 9aee29e

Browse files
committed
Merge branch 'develop' into feature/tile-show
* develop: (26 commits) Set next development version. Tweaks to get .whl file under the default size limit on PyPi. Set version to 0.8.0. Removed tile display contrast fiddling. Quiet down pip; cache .local. Additional CI + Python dependency attempts. Final documentation tweaks. Move PegdownMarkdownFormatter to docs class Edits: languages.pymd & reference.pymd Fix setup.py dependency, fix rf_rasterize signature regression in unit test Edits: aggregation.pymd, supervised-learning.pymd, unsupervised-learning.pymd, time-series.pymd Edits: local-algebra.pymd, nodata-handling.pymd. Rendering tweaks. Edits: raster-write.pymd & vector-data.pymd. Python SetupTools + TravisCI == Painful Combo. Edits: raster-io.md, raster-catalogs.pymd, raster-read.pymd. Fixes to PDF generation code. Edits: concepts.md & getting-started.md. Edits: index.md & description.md Tweaks to time-series.pymd to lower memory pressure and remove SQL. Tweaked pweave markdown generator. ... # Conflicts: # pyrasterframes/src/main/python/pyrasterframes/rf_ipython.py
2 parents 639ef9f + 6ac3d47 commit 9aee29e

File tree

42 files changed

+558
-324
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+558
-324
lines changed

.circleci/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ _save_cache: &save_cache
2828
- ~/.cache/coursier
2929
- ~/.ivy2/cache
3030
- ~/.sbt
31-
32-
before_script:
33-
- ulimit -c unlimited -S
31+
- ~/.local
3432

3533
jobs:
3634
test:
@@ -68,6 +66,7 @@ jobs:
6866
<<: *restore_cache
6967

7068
- run: ulimit -c unlimited -S
69+
- run: pip3 install --quiet --user -r pyrasterframes/src/main/python/requirements.txt
7170
- run:
7271
command: cat /dev/null | sbt makeSite
7372
no_output_timeout: 30m
@@ -191,6 +190,7 @@ workflows:
191190
branches:
192191
only:
193192
- /feature\/.*docs.*/
193+
- /docs\/.*/
194194

195195
nightly:
196196
triggers:

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ cache:
1010
- $HOME/.ivy2/cache
1111
- $HOME/.sbt/boot
1212
- $HOME/.rf_cache
13+
- $HOME/.cache/coursier
1314

1415
scala:
1516
- 2.11.11
@@ -24,7 +25,7 @@ addons:
2425
- pandoc
2526

2627
install:
27-
- pip install rasterio shapely pandas numpy
28+
- pip install rasterio shapely pandas numpy pweave
2829
- wget -O - https://piccolo.link/sbt-1.2.8.tgz | tar xzf -
2930

3031
script:

build.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
addCommandAlias("makeSite", "docs/makeSite")
2323
addCommandAlias("previewSite", "docs/previewSite")
24+
addCommandAlias("ghpagesPushSite", "docs/ghpagesPushSite")
2425
addCommandAlias("console", "datasource/console")
2526

2627
// Prefer our own IntegrationTest config definition, which inherits from Test.
@@ -36,6 +37,7 @@ lazy val root = project
3637
lazy val `rf-notebook` = project
3738
.dependsOn(pyrasterframes)
3839
.enablePlugins(RFAssemblyPlugin, DockerPlugin)
40+
.settings(publish / skip := true)
3941

4042
lazy val core = project
4143
.enablePlugins(BuildInfoPlugin)

core/src/main/scala/org/locationtech/rasterframes/RasterFunctions.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,11 @@ trait RasterFunctions {
280280
udf(F.rasterize(_: Geometry, _: Geometry, _: Int, cols, rows)).apply(geometry, bounds, value)
281281
)
282282

283+
def rf_rasterize(geometry: Column, bounds: Column, value: Column, cols: Column, rows: Column): TypedColumn[Any, Tile] =
284+
withTypedAlias("rf_rasterize", geometry)(
285+
udf(F.rasterize).apply(geometry, bounds, value, cols, rows)
286+
)
287+
283288
/** Reproject a column of geometry from one CRS to another.
284289
* @param sourceGeom Geometry column to reproject
285290
* @param srcCRS Native CRS of `sourceGeom` as a literal

core/src/main/scala/org/locationtech/rasterframes/expressions/accessors/RealizeTile.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import org.locationtech.rasterframes.model.TileContext
4242
case class RealizeTile(child: Expression) extends UnaryRasterOp with CodegenFallback {
4343
override def dataType: DataType = TileType
4444

45-
override def nodeName: String = "rf_realize_tile"
45+
override def nodeName: String = "rf_tile"
4646
implicit val tileSer = TileUDT.tileSerializer
4747

4848
override protected def eval(tile: Tile, ctx: Option[TileContext]): Any =

core/src/main/scala/org/locationtech/rasterframes/util/package.scala

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import org.apache.spark.sql.catalyst.analysis.UnresolvedAttribute
3636
import org.apache.spark.sql.catalyst.expressions.{Alias, Expression, NamedExpression}
3737
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
3838
import org.apache.spark.sql.catalyst.rules.Rule
39+
import org.apache.spark.sql.functions._
3940
import org.apache.spark.sql.rf._
4041
import org.apache.spark.sql.types.StringType
4142
import org.apache.spark.sql._
@@ -183,6 +184,27 @@ package object util {
183184
}
184185
}
185186

187+
implicit class DFWithPrettyPrint(val df: Dataset[_]) extends AnyVal {
188+
def toMarkdown(numRows: Int = 5, truncate: Boolean = false): String = {
189+
import df.sqlContext.implicits._
190+
val cols = df.columns
191+
val header = cols.mkString("| ", " | ", " |") + "\n" + ("|---" * cols.length) + "|\n"
192+
val stringifiers = cols
193+
.map(c => s"`$c`")
194+
.map(c => df.col(c).cast(StringType))
195+
.map(c => if (truncate) substring(c, 1, 40) else c)
196+
val cat = concat_ws(" | ", stringifiers: _*)
197+
val body = df
198+
.select(cat).limit(numRows)
199+
.as[String]
200+
.collect()
201+
.map(_.replaceAll("\\[", "\\\\["))
202+
.map(_.replace('\n', '↩'))
203+
.mkString("| ", " |\n| ", " |")
204+
header + body
205+
}
206+
}
207+
186208
object Shims {
187209
// GT 1.2.1 to 2.0.0
188210
def toArrayTile[T <: CellGrid](tile: T): T =

core/src/test/scala/org/locationtech/rasterframes/ExtensionMethodSpec.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class ExtensionMethodSpec extends TestEnvironment with TestData with SubdivideSu
6767
// Not sure why implicit resolution isn't handling this properly.
6868
implicit val enc = Encoders.tuple(crsEncoder, Encoders.STRING, crsEncoder, Encoders.scalaDouble)
6969
val df = Seq((pe.crs, "fred", pe.crs, 34.0)).toDF("c1", "s", "c2", "n")
70-
df.crsColumns.size should be (2)
70+
df.crsColumns.size should be(2)
7171
}
7272

7373
it("should split TileLayout") {
@@ -92,10 +92,10 @@ class ExtensionMethodSpec extends TestEnvironment with TestData with SubdivideSu
9292

9393
it("should split key") {
9494
val s1 = SpatialKey(0, 0).subdivide(2)
95-
assert(s1 === Seq(SpatialKey(0,0), SpatialKey(1,0), SpatialKey(0,1), SpatialKey(1,1)))
95+
assert(s1 === Seq(SpatialKey(0, 0), SpatialKey(1, 0), SpatialKey(0, 1), SpatialKey(1, 1)))
9696

9797
val s2 = SpatialKey(2, 3).subdivide(3)
98-
assert(s2 === Seq(SpatialKey(6,9), SpatialKey(7,9), SpatialKey(8,9), SpatialKey(6,10), SpatialKey(7,10), SpatialKey(8,10), SpatialKey(6,11), SpatialKey(7,11), SpatialKey(8,11)))
98+
assert(s2 === Seq(SpatialKey(6, 9), SpatialKey(7, 9), SpatialKey(8, 9), SpatialKey(6, 10), SpatialKey(7, 10), SpatialKey(8, 10), SpatialKey(6, 11), SpatialKey(7, 11), SpatialKey(8, 11)))
9999
}
100100

101101
it("should split TileLayerMetadata[SpatialKey]") {
@@ -107,7 +107,12 @@ class ExtensionMethodSpec extends TestEnvironment with TestData with SubdivideSu
107107

108108
val divided = tlm.subdivide(2)
109109

110-
assert(divided.tileLayout.tileDimensions === (tileSize/2, tileSize/2))
110+
assert(divided.tileLayout.tileDimensions === (tileSize / 2, tileSize / 2))
111+
}
112+
113+
it("should render Markdown") {
114+
import org.locationtech.rasterframes.util._
115+
rf.toMarkdown().count(_ == '|') shouldBe >=(3 * 5)
111116
}
112117
}
113118
}

docs/README.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,21 @@ The build constructs in `<src-root>/docs` are (due to legacy reasons) the top-le
2525
}
2626
```
2727

28+
## Building the docs
29+
30+
To build the static site locally:
31+
32+
sbt makeSite
33+
34+
The site will be at `<src-root>/docs/target/site/index.html`.
35+
36+
37+
To start an interactive server running the docs:
38+
39+
sbt previewSite
40+
41+
The sbt server log a message with an address to view the site.
42+
2843
## Content Development Process
2944

3045
Start with one of the existing files in `<src-root>/pyrasterframes/src/main/python/docs` as a template. [`local-algebra.pymd`](../pyrasterframes/src/main/python/docs/local-algebra.pymd) is a good example. If the content will have code blocks you want evaluated an results injected into the output, use the file extension `.pymd`. If the content doesn't use evaluatable code blocks, use `.md`.
@@ -44,9 +59,9 @@ To set up an environment whereby you can easily test/evaluate your code blocks d
4459
[info] Set current project to RasterFrames (in build file:<src-root>/)
4560
sbt:RasterFrames>
4661
```
47-
2. The first time you check out the code, or whenever RasterFrames code is updated, you need to build the project artifacts so they are available for Pweave.
62+
2. The first time you check out the code, or whenever RasterFrames code is updated, you need to build the project artifacts so they are available for Pweave. Some docs also refer to test resources, so the easiest way to do it is to run the unit tests.
4863
```
49-
sbt:RasterFrames> pyrasterframes/package
64+
sbt:RasterFrames> pyrasterframes/test
5065
[info] Compiling 4 Scala sources to <src-root>/core/target/scala-2.11/classes ...
5166
... lots of noise ...
5267
[info] PyRasterFrames assembly written to '<src-root>/pyrasterframes/target/python/deps/jars/pyrasterframes-assembly-0.8.0-SNAPSHOT.jar'
@@ -66,7 +81,7 @@ To set up an environment whereby you can easily test/evaluate your code blocks d
6681
sbt:RasterFrames> pyrasterframes/doc
6782
```
6883
There's a command alias for this last step: `pyDocs`.
69-
4. To evaluate a single `.pymd` file, you pass the `-s` option and the filename relative to the `python` directory:
84+
4. To evaluate a single `.pymd` file, you pass the `-s` option and the filename relative to the `pyraterframes/src/main/python` directory. You can also specify the output [format](http://mpastell.com/pweave/formats.html) with the `-f` argument.
7085
```
7186
sbt:RasterFrames> pyrasterframes/pySetup pweave -s docs/getting-started.pymd
7287
[info] Synchronizing 44 files to '<src-root>/pyrasterframes/target/python'
@@ -82,7 +97,7 @@ To set up an environment whereby you can easily test/evaluate your code blocks d
8297
Weaved docs/getting-started.pymd to docs/getting-started.md
8398
```
8499
5. The _output_ Markdown files are written to `<src-root>/pyrasterframes/target/python/docs`. _Note_: don't edit any files in the `pyrasterframes/target` directory... they will get overwritten each time `sbt` runs a command.
85-
6. During content development it's sometimes helpful to see the output rendered as basic HTML. To do this, add the `-d html` option to the pweave command:
100+
6. During content development it's sometimes helpful to see the output rendered as basic HTML. To do this, add the `-f html` option to the pweave command:
86101
```
87102
sbt:RasterFrames> pyrasterframes/pySetup pweave -f html -s docs/getting-started.pymd
88103
[info] Synchronizing 54 files to '<src-roog>/pyrasterframes/target/python'
@@ -103,8 +118,11 @@ To set up an environment whereby you can easily test/evaluate your code blocks d
103118
104119
## Notebooks
105120
106-
The `rf-notebooks` sub-project creates a Docker image with Jupyter Notebooks pre-configured with RasterFrames. Any `.pymd` file under `.../python/docs/` is converted to an evaluated Jupyter Notebook and included as a part of the build (an additional bonus of the Pweave tool).
121+
The `rf-notebooks` sub-project creates a Docker image with Jupyter Notebooks pre-configured with RasterFrames. Any `.pymd` file under `.../python/docs/` is converted to an evaluated Jupyter Notebook and included as a part of the build.
107122
108123
## Submission Process
109124
110-
Submit new and updated documentation as a PR against locationtech/rasterframes. Make sure you've signed the Eclipse Foundation ECA and you ["Signed-off-by:"](https://stackoverflow.com/questions/1962094/what-is-the-sign-off-feature-in-git-for) each commit in the PR. The "Signed-off-by" address needs to be the exact same one as registered with the [Eclipse Foundation](https://wiki.eclipse.org/Development_Resources/Contributing_via_Git).
125+
Submit new and updated documentation as a PR against locationtech/rasterframes. Make sure you've signed the Eclipse Foundation ECA and you ["Signed-off-by:"](https://stackoverflow.com/questions/1962094/what-is-the-sign-off-feature-in-git-for) each commit in the PR. The "Signed-off-by" email address needs to be the exact same one as registered with the [Eclipse Foundation](https://wiki.eclipse.org/Development_Resources/Contributing_via_Git).
126+
127+
If you are using circle CI, the circle configuration is set up to build the docs with `sbt makeSite` for branch names matching `feature/.*docs.*` or `docs/.*`
128+

docs/build.sbt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ makePDF := {
88

99
// Get the python source directory configured in the root project.
1010
val base = (Compile / paradox / sourceDirectories).value.find(_.toString.contains("python")).head
11-
println(base)
1211

1312
// Hard coded lacking any simple way of determining order.
1413
val files = Seq(
@@ -42,9 +41,9 @@ makePDF := {
4241
work.mkdirs()
4342

4443
val prepro = files.zipWithIndex.map { case (f, i)
45-
val dest = work / f"$i%02d.md"
44+
val dest = work / f"$i%02d-${f.getName}%s"
4645
// Filter cross links and add a newline
47-
(Seq("sed", "-e", """s/@ref:\[\([^]]*\)\](.*)/_\1_/g;s/@@.*//g""", f.toString) #> dest).!
46+
(Seq("sed", "-e", """s/@ref://g;s/@@.*//g""", f.toString) #> dest).!
4847
// Add newline at the end of the file so as to make pandoc happy
4948
("echo" #>> dest).!
5049
("echo \\pagebreak" #>> dest).!
@@ -56,7 +55,7 @@ makePDF := {
5655
val header = (Compile / sourceDirectory).value / "latex" / "header.latex"
5756

5857
val args = "pandoc" ::
59-
"--from=markdown" ::
58+
"--from=markdown+pipe_tables" ::
6059
"--to=pdf" ::
6160
"-t" :: "latex" ::
6261
"-s" ::
@@ -65,7 +64,6 @@ makePDF := {
6564
"-V" :: "author:Astraea, Inc." ::
6665
"-V" :: "geometry:margin=0.75in" ::
6766
"-V" :: "papersize:letter" ::
68-
"-V" :: "links-as-notes" ::
6967
"--include-in-header" :: header.toString ::
7068
"-o" :: output.toString ::
7169
prepro.map(_.toString).toList

docs/src/main/latex/header.latex

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
\DeclareUnicodeCharacter{2218}{$\circ$}
2-
\DeclareUnicodeCharacter{2714}{$\checkmark}
2+
\DeclareUnicodeCharacter{2714}{$\checkmark$}
3+
\DeclareUnicodeCharacter{21A9}{$\newline$}
4+
\hypersetup{
5+
colorlinks=true,
6+
linkcolor=blue,
7+
allbordercolors={0 0 0},
8+
pdfborderstyle={/S/U/W 1}
9+
}

0 commit comments

Comments
 (0)