Skip to content

Commit 6558b0b

Browse files
committed
Merge commit '18ed6790e53e124d2b562bf3b7a7c1714b538705' into docs/editorial-review-1
* commit '18ed6790e53e124d2b562bf3b7a7c1714b538705': Move PegdownMarkdownFormatter to docs class Fix setup.py dependency, fix rf_rasterize signature regression in unit test reverse sort Deterministic pymd file order Update docs readme Fix broken ref, attempt trigger circle build for docs/* branches
2 parents 186e82a + 18ed679 commit 6558b0b

File tree

5 files changed

+58
-22
lines changed

5 files changed

+58
-22
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ workflows:
191191
branches:
192192
only:
193193
- /feature\/.*docs.*/
194+
- /docs\/.*/
194195

195196
nightly:
196197
triggers:

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+

pyrasterframes/src/main/python/docs/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import os
2222
from pyspark.sql import DataFrame
2323
from pyrasterframes import RFContext
24+
from pweave import PwebPandocFormatter
25+
2426

2527
def docs_dir():
2628
return os.path.dirname(os.path.realpath(__file__))
@@ -38,3 +40,12 @@ def resource_dir():
3840

3941
def resource_dir_uri():
4042
return 'file://' + resource_dir()
43+
44+
45+
class PegdownMarkdownFormatter(PwebPandocFormatter):
46+
def __init__(self, *args, **kwargs):
47+
super().__init__(*args, **kwargs)
48+
49+
# Pegdown doesn't support the width and label options.
50+
def make_figure_string(self, figname, width, label, caption=""):
51+
return "![%s](%s)" % (caption, figname)

pyrasterframes/src/main/python/setup.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,6 @@ def _divided(msg):
4747
return divider + '\n' + msg + '\n' + divider
4848

4949

50-
from pweave import PwebPandocFormatter
51-
52-
class PegdownMarkdownFormatter(PwebPandocFormatter):
53-
def __init__(self, *args, **kwargs):
54-
super().__init__(*args, **kwargs)
55-
56-
# Pegdown doesn't support the width and label options.
57-
def make_figure_string(self, figname, width, label, caption=""):
58-
return "![%s](%s)" % (caption, figname)
59-
6050
class PweaveDocs(distutils.cmd.Command):
6151
"""A custom command to run documentation scripts through pweave."""
6252
description = 'Pweave PyRasterFrames documentation scripts'
@@ -67,6 +57,7 @@ class PweaveDocs(distutils.cmd.Command):
6757
('quick=', 'q', 'Check to see if the source file is newer than existing output before building. Defaults to `False`.')
6858
]
6959

60+
7061
def initialize_options(self):
7162
"""Set default values for options."""
7263
# Each user option must be listed here with their default value.
@@ -96,6 +87,8 @@ def run(self):
9687
"""Run pweave."""
9788
import traceback
9889
import pweave
90+
from docs import PegdownMarkdownFormatter
91+
9992
bad_words = ["Error"]
10093
pweave.rcParams["chunk"]["defaultoptions"].update({'wrap': False, 'dpi': 175})
10194
if self.format == 'markdown':
@@ -104,7 +97,7 @@ def run(self):
10497
'description': 'Pegdown compatible markdown'
10598
}
10699

107-
for file in self.files:
100+
for file in sorted(self.files, reverse=True):
108101
name = path.splitext(path.basename(file))[0]
109102
dest = self.dest_file(file)
110103

pyrasterframes/src/main/python/tests/VectorTypesTests.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def some_point(g):
9797
pandas_df_out.poly_len.values
9898
)
9999

100-
def test_rasterize(self):
100+
def test_geometry_udf(self):
101101
from geomesa_pyspark.types import PolygonUDT
102102
# simple test that raster contents are not invalid
103103

@@ -117,12 +117,25 @@ def area(g):
117117
area_result = area.collect()
118118
self.assertTrue(all([r[0] for r in area_result]))
119119

120-
cols = 194
121-
rows = 250
122-
with_raster = with_poly.withColumn('rasterized', rf_rasterize('poly', 'geometry', lit(16), cols, rows))
123-
# expect a 4 by 4 cell
120+
def test_rasterize(self):
121+
from geomesa_pyspark.types import PolygonUDT
122+
123+
@udf(PolygonUDT())
124+
def buffer(g, d):
125+
return g.buffer(d)
126+
127+
# start with known polygon, the tile extents, **negative buffered** by 10 cells
128+
buf_cells = 10
129+
with_poly = self.rf.withColumn('poly', buffer(self.rf.geometry, lit(-15 * buf_cells))) # cell res is 15x15
130+
131+
# rasterize value 16 into buffer shape.
132+
cols = 194 # from dims of tile
133+
rows = 250 # from dims of tile
134+
with_raster = with_poly.withColumn('rasterized',
135+
rf_rasterize('poly', 'geometry', lit(16), lit(cols), lit(rows)))
124136
result = with_raster.select(rf_tile_sum(rf_local_equal_int(with_raster.rasterized, 16)),
125137
rf_tile_sum(with_raster.rasterized))
138+
#
126139
expected_burned_in_cells = (cols - 2 * buf_cells) * (rows - 2 * buf_cells)
127140
self.assertEqual(result.first()[0], float(expected_burned_in_cells))
128141
self.assertEqual(result.first()[1], 16. * expected_burned_in_cells)

0 commit comments

Comments
 (0)