Skip to content

Commit ce07462

Browse files
authored
Merge pull request planetlabs#118 from planetlabs/imports-notebook-112
Imports notebook 112
2 parents f973611 + 7214aa3 commit ce07462

File tree

4 files changed

+119
-41
lines changed

4 files changed

+119
-41
lines changed

CONTRIBUTING.md

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,39 @@
11
# Contributing to Notebooks
22

3-
## Notebook Naming
3+
# Notebooks
44

5-
Notebooks cannot have spaces in the paths. Use underscores instead. This is
5+
## Names
6+
7+
Notebook filenames cannot have spaces. Use underscores instead. This is
68
because pytest does not like spaces in command line arguments.
79

8-
## Docker Image Validation
10+
## Dependencies
11+
12+
When a new notebook has a dependency that is not yet supported by the Docker image,
13+
a new Docker image must be built. Additionally, add the new dependency to the
14+
[imports_test notebook](development-notebooks/imports_test.ipynb).
15+
16+
## Skipping Validation
17+
18+
To enable validation of the Docker image, every notebook should run successfully
19+
when run from the command line. For notebooks where that just is not possible,
20+
the notebooks can be excluded from automated running by adding its path to
21+
[tests/skip_notebooks](tests/skip_notebooks). Excluding a notebook from automated running
22+
means that it is excluded from Docker Image validation. **If a notebook is
23+
skipped, it will not be guaranteed to be supported by the Docker image.**
24+
25+
# Docker Image
26+
27+
## Validation
28+
29+
**Every time** the Docker image is changed, at the very least ensure that the
30+
python packages still import without error by running the
31+
[imports_test notebook](development-notebooks/imports_test.ipynb).
932

10-
The docker image must be able to run all notebooks. Whenever a change is made to
11-
the docker image, it must be validated. This can be accomplished by automatically
12-
running all of the notebooks using the supplied test script. This is accomplished
13-
by running the notebook in interactive mode, achieved by adding `/bin/bash` to
33+
It is also strongly recommended that you ensure the Docker image can run all
34+
of the notebooks in the repository. This can be accomplished by automatically
35+
running all of the notebooks using the supplied test script. To run the test script,
36+
run the notebook in interactive mode, achieved by adding `/bin/bash` to
1437
the container run command, e.g.
1538
```bash
1639
docker run -it --rm -p 8888:8888 -v $PWD:/home/jovyan/work -e PL_API_KEY='[YOUR-API-KEY]' planet-notebooks /bin/bash
@@ -35,14 +58,10 @@ From the root directory within the docker container, run one of the following:
3558
$> pytest tests/test_notebooks.py --notebooks "$(grep -rl import <package> jupyter-notebooks/)"
3659
```
3760

38-
## Automated Running and Skipping
39-
40-
To enable validation of the Docker image, every notebook should run successfully
41-
when run from the command line. For notebooks where that just is not possible,
42-
the notebooks can be excluded from automated running by adding its path to
43-
`tests/skip_notebooks`. Excluding a notebook from automated running
44-
means that it is excluded from Docker Image validation. **If a notebook is
45-
skipped, it will not be guaranteed to be supported by the Docker image.**
61+
## Skipping Notebooks
4662

47-
Skipping of notebooks within `skip_notebooks` can be achieved with by adding the
48-
`--no-skip` option to the pytest command.
63+
Some notebooks are purposefully skipped in the validation process because they
64+
do not run successfully from the command line. These notebooks are specified in
65+
[tests/skip_notebooks](tests/skip_notebooks). Skipping of notebooks within
66+
`skip_notebooks` can be disabled by adding the `--no-skip` option to the pytest
67+
command.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Imports Test\n",
8+
"\n",
9+
"This notebook imports all of the dependencies in this repo to identify any import errors. The purpose of this notebook is to provide some basic testing for development involving the Docker image.\n",
10+
"\n",
11+
"Every once in a while, check to see all these packages are used\n",
12+
"\n",
13+
"```\n",
14+
"find . -type f -print0 | xargs -0 grep \"import <package>\"\n",
15+
"```"
16+
]
17+
},
18+
{
19+
"cell_type": "code",
20+
"execution_count": 1,
21+
"metadata": {},
22+
"outputs": [],
23+
"source": [
24+
"# please keep this in alphabetical order\n",
25+
"import cv2\n",
26+
"import fiona\n",
27+
"import geojson\n",
28+
"import geojsonio\n",
29+
"import geopandas\n",
30+
"import ipyleaflet\n",
31+
"import ipywidgets\n",
32+
"import matplotlib\n",
33+
"import mercantile\n",
34+
"import numpy\n",
35+
"from osgeo import gdal, osr\n",
36+
"import pandas\n",
37+
"import planet\n",
38+
"import pyproj\n",
39+
"import pytest\n",
40+
"import rasterio\n",
41+
"import requests\n",
42+
"import scipy\n",
43+
"import shapely\n",
44+
"import six # python2/3 compatibility\n",
45+
"import skimage\n",
46+
"import sklearn\n",
47+
"import tqdm"
48+
]
49+
},
50+
{
51+
"cell_type": "code",
52+
"execution_count": null,
53+
"metadata": {},
54+
"outputs": [],
55+
"source": []
56+
}
57+
],
58+
"metadata": {
59+
"kernelspec": {
60+
"display_name": "Python 3",
61+
"language": "python",
62+
"name": "python3"
63+
},
64+
"language_info": {
65+
"codemirror_mode": {
66+
"name": "ipython",
67+
"version": 3
68+
},
69+
"file_extension": ".py",
70+
"mimetype": "text/x-python",
71+
"name": "python",
72+
"nbconvert_exporter": "python",
73+
"pygments_lexer": "ipython3",
74+
"version": "3.7.6"
75+
}
76+
},
77+
"nbformat": 4,
78+
"nbformat_minor": 4
79+
}

jupyter-notebooks/webtiles/visualize_imagery_over_time.ipynb

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,6 @@
1515
"## Setup"
1616
]
1717
},
18-
{
19-
"cell_type": "markdown",
20-
"metadata": {},
21-
"source": [
22-
"#### Install additional dependencies\n",
23-
"If you don't already have mercantile in your current jupyter environment, you can install it now."
24-
]
25-
},
26-
{
27-
"cell_type": "code",
28-
"execution_count": null,
29-
"metadata": {},
30-
"outputs": [],
31-
"source": [
32-
"!pip install mercantile"
33-
]
34-
},
3518
{
3619
"cell_type": "markdown",
3720
"metadata": {},
@@ -388,7 +371,7 @@
388371
"name": "python",
389372
"nbconvert_exporter": "python",
390373
"pygments_lexer": "ipython3",
391-
"version": "3.6.7"
374+
"version": "3.7.6"
392375
}
393376
},
394377
"nbformat": 4,

planet-notebook-docker/requirements.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1+
# changes here should be reflected in
2+
# ../development-notebooks/imports_test.ipynb
13
# please keep this in alphabetical order
2-
bokeh
3-
cartopy
4-
datashader
5-
descartes
64
fiona
75
gdal
86
geojson
97
geojsonio
108
geopandas
11-
geoviews
12-
hvplot
139
ipyleaflet
1410
ipywidgets
1511
matplotlib
12+
mercantile
1613
numpy
1714
# for pip, use opencv-python
1815
opencv

0 commit comments

Comments
 (0)