Skip to content

Commit 13f9ca9

Browse files
authored
Add pre-commit cli (#1914)
* Add pre-commit cli * Remove codespell * Add black formatting to pre-commit
1 parent 5523f36 commit 13f9ca9

File tree

21 files changed

+252
-243
lines changed

21 files changed

+252
-243
lines changed

.github/workflows/docs-build.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ jobs:
2525
run: |
2626
python -m pip install --upgrade pip
2727
pip install --user --no-cache-dir Cython
28-
pip install codespell
2928
pip install .[all]
30-
- name: Discover typos with codespell
31-
run: codespell --skip="*.csv,*.geojson,*.json,*.yml*.js,*.html,*cff,*.pdf" --ignore-words-list="aci,acount,acounts,fallow,ges,hart,hist,nd,ned,ois,wqs,watermask"
3229
- name: LOAD EE CREDENTIALS
3330
run: python ./.github/ee_token.py
3431
env:

.github/workflows/docs.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@ jobs:
2727
run: |
2828
python -m pip install --upgrade pip
2929
pip install --user --no-cache-dir Cython
30-
pip install codespell
3130
pip install .[all]
32-
- name: Discover typos with codespell
33-
run: codespell --skip="*.csv,*.geojson,*.json,*.yml*.js,*.html,*cff,*.pdf" --ignore-words-list="aci,acount,acounts,fallow,ges,hart,hist,nd,ned,ois,wqs,watermask"
3431
- name: LOAD EE CREDENTIALS
3532
run: python ./.github/ee_token.py
3633
env:

.github/workflows/macos.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ jobs:
2929
run: |
3030
python -m pip install --upgrade pip
3131
pip install --no-cache-dir Cython
32-
pip install codespell -r requirements.txt
32+
pip install -r requirements.txt
3333
pip install .

.github/workflows/pypi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ jobs:
2626
TWINE_USERNAME: ${{ secrets.PYPI_USERS }}
2727
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
2828
run: |
29-
pip install build
29+
pip install build
3030
python -m build
3131
twine upload dist/*

.github/workflows/ubuntu.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,7 @@ jobs:
3131
gdalinfo --version
3232
- name: Install dependencies
3333
run: |
34-
pip install codespell
3534
pip install .[all]
36-
- name: Discover typos with codespell
37-
run: |
38-
pip install codespell
39-
codespell --skip="*.csv,*.geojson,*.json,*.yml*.js,*.html,*cff,*.pdf" --ignore-words-list="aci,acount,acounts,fallow,ges,hart,hist,nd,ned,ois,wqs,watermask"
4035
- name: PKG-TEST
4136
run: |
4237
python -m unittest discover tests/

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ jobs:
2727
run: |
2828
python -m pip install --upgrade pip
2929
pip install --no-cache-dir Cython
30-
pip install -r codespell requirements.txt
30+
pip install -r requirements.txt
3131
pip install .

.pre-commit-config.yaml

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
11
repos:
2-
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.5.0
4-
hooks:
5-
- id: check-toml
6-
- id: check-yaml
7-
- id: end-of-file-fixer
8-
types: [python]
9-
- id: trailing-whitespace
10-
- id: requirements-txt-fixer
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: check-toml
6+
- id: check-yaml
7+
- id: end-of-file-fixer
8+
types: [python]
9+
- id: trailing-whitespace
10+
- id: requirements-txt-fixer
11+
- id: check-added-large-files
12+
args: ["--maxkb=500"]
1113

12-
- repo: https://github.com/codespell-project/codespell
13-
rev: v2.2.6
14-
hooks:
15-
- id: codespell
16-
args: [--toml, pyproject-codespell.precommit-toml]
14+
- repo: https://github.com/psf/black
15+
rev: 24.2.0
16+
hooks:
17+
- id: black
18+
19+
- repo: https://github.com/codespell-project/codespell
20+
rev: v2.2.6
21+
hooks:
22+
- id: codespell
23+
args: [--toml, pyproject-codespell.precommit-toml]

README.rst

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ geemap
2929
.. image:: https://github.com/gee-community/geemap/workflows/docs/badge.svg
3030
:target: https://geemap.org
3131

32-
.. image:: https://img.shields.io/badge/YouTube-Channel-red
32+
.. image:: https://img.shields.io/badge/YouTube-Channel-red
3333
:target: https://youtube.com/@giswqs
3434

3535
.. image:: https://img.shields.io/badge/License-MIT-yellow.svg
@@ -42,7 +42,12 @@ geemap
4242
:target: https://joss.theoj.org/papers/10.21105/joss.02305
4343

4444
.. image:: https://badges.gitter.im/Join%20Chat.svg
45-
:target: https://matrix.to/#/#geemap:gitter.im
45+
:target: https://matrix.to/#/#geemap:gitter.im
46+
47+
.. image:: https://results.pre-commit.ci/badge/github/gee-community/geemap/master.svg
48+
:target: https://results.pre-commit.ci/latest/github/gee-community/geemap/master
49+
:alt: pre-commit.ci status
50+
4651

4752
**A Python package for interactive geospatial analysis and visualization with Google Earth Engine.**
4853

@@ -78,10 +83,10 @@ purchasing the book, please visit this URL: https://locatepress.com/book/gee.
7883
Introduction
7984
------------
8085

81-
**Geemap** is a Python package for geospatial analysis and visualization with `Google Earth Engine <https://earthengine.google.com/>`__ (GEE), which is a cloud computing platform with a `multi-petabyte catalog <https://developers.google.com/earth-engine/datasets/>`__ of satellite imagery and geospatial datasets. During the past few years,
82-
GEE has become very popular in the geospatial community and it has empowered numerous environmental applications at local, regional, and global scales. GEE provides both JavaScript and Python APIs for
83-
making computational requests to the Earth Engine servers. Compared with the comprehensive `documentation <https://developers.google.com/earth-engine>`__ and interactive IDE (i.e., `GEE JavaScript Code Editor <https://code.earthengine.google.com/>`__) of the GEE JavaScript API,
84-
the GEE Python API has relatively little documentation and limited functionality for visualizing results interactively. The **geemap** Python package was created to fill this gap. It is built upon `ipyleaflet <https://github.com/jupyter-widgets/ipyleaflet>`__ and `ipywidgets <https://github.com/jupyter-widgets/ipywidgets>`__, and enables users to
86+
**Geemap** is a Python package for geospatial analysis and visualization with `Google Earth Engine <https://earthengine.google.com/>`__ (GEE), which is a cloud computing platform with a `multi-petabyte catalog <https://developers.google.com/earth-engine/datasets/>`__ of satellite imagery and geospatial datasets. During the past few years,
87+
GEE has become very popular in the geospatial community and it has empowered numerous environmental applications at local, regional, and global scales. GEE provides both JavaScript and Python APIs for
88+
making computational requests to the Earth Engine servers. Compared with the comprehensive `documentation <https://developers.google.com/earth-engine>`__ and interactive IDE (i.e., `GEE JavaScript Code Editor <https://code.earthengine.google.com/>`__) of the GEE JavaScript API,
89+
the GEE Python API has relatively little documentation and limited functionality for visualizing results interactively. The **geemap** Python package was created to fill this gap. It is built upon `ipyleaflet <https://github.com/jupyter-widgets/ipyleaflet>`__ and `ipywidgets <https://github.com/jupyter-widgets/ipywidgets>`__, and enables users to
8590
analyze and visualize Earth Engine datasets interactively within a Jupyter-based environment.
8691

8792
**Geemap** is intended for students and researchers, who would like to utilize the Python ecosystem of diverse libraries and tools to explore Google Earth Engine. It is also designed for existing GEE users who would like to transition from the GEE JavaScript API to Python API. The automated JavaScript-to-Python `conversion module <https://github.com/gee-community/geemap/blob/master/geemap/conversion.py>`__ of the **geemap** package
@@ -91,10 +96,10 @@ For video tutorials and notebook examples, please visit `<https://geemap.org/tut
9196

9297
If you find geemap useful in your research, please consider citing the following papers to support my work. Thank you for your support.
9398

94-
- Wu, Q., (2020). geemap: A Python package for interactive mapping with Google Earth Engine. *The Journal of Open Source Software*, 5(51), 2305. `<https://doi.org/10.21105/joss.02305>`__
99+
- Wu, Q., (2020). geemap: A Python package for interactive mapping with Google Earth Engine. *The Journal of Open Source Software*, 5(51), 2305. `<https://doi.org/10.21105/joss.02305>`__
95100
- Wu, Q., Lane, C. R., Li, X., Zhao, K., Zhou, Y., Clinton, N., DeVries, B., Golden, H. E., & Lang, M. W. (2019). Integrating LiDAR data and multi-temporal aerial imagery to map wetland inundation dynamics using Google Earth Engine. *Remote Sensing of Environment*, 228, 1-13. https://doi.org/10.1016/j.rse.2019.04.015 (`pdf <https://gishub.org/2019_rse>`_ | `source code <https://doi.org/10.6084/m9.figshare.8864921>`_)
96101

97-
Check out the geemap workshop presented at the GeoPython Conference 2021. This workshop gives a comprehensive introduction to the key features of geemap.
102+
Check out the geemap workshop presented at the GeoPython Conference 2021. This workshop gives a comprehensive introduction to the key features of geemap.
98103

99104
.. image:: https://img.youtube.com/vi/wGjpjh9IQ5I/0.jpg
100105
:target: https://www.youtube.com/watch?v=wGjpjh9IQ5I
@@ -155,7 +160,7 @@ To use **geemap**, you must first `sign up <https://earthengine.google.com/signu
155160
conda create -n gee python=3.10
156161
conda activate gee
157162
conda install -n base mamba -c conda-forge
158-
mamba install geemap -c conda-forge
163+
mamba install geemap -c conda-forge
159164
160165
If you have installed **geemap** before and want to upgrade to the latest version, you can run the following command in your terminal:
161166

@@ -165,7 +170,7 @@ If you have installed **geemap** before and want to upgrade to the latest versio
165170
166171
167172
If you use conda, you can update geemap to the latest version by running the following command in your terminal:
168-
173+
169174
.. code:: python
170175
171176
conda update -c conda-forge geemap
@@ -184,11 +189,11 @@ To install the development version from GitHub directly within Jupyter notebook
184189
185190
import geemap
186191
geemap.update_package()
187-
192+
188193
Citations
189194
---------
190195

191196
To support my work, please consider citing the following articles:
192197

193-
- **Wu, Q.**, (2020). geemap: A Python package for interactive mapping with Google Earth Engine. *The Journal of Open Source Software*, 5(51), 2305. https://doi.org/10.21105/joss.02305
198+
- **Wu, Q.**, (2020). geemap: A Python package for interactive mapping with Google Earth Engine. *The Journal of Open Source Software*, 5(51), 2305. https://doi.org/10.21105/joss.02305
194199
- **Wu, Q.**, Lane, C. R., Li, X., Zhao, K., Zhou, Y., Clinton, N., DeVries, B., Golden, H. E., & Lang, M. W. (2019). Integrating LiDAR data and multi-temporal aerial imagery to map wetland inundation dynamics using Google Earth Engine. *Remote Sensing of Environment*, 228, 1-13. https://doi.org/10.1016/j.rse.2019.04.015 (`pdf <https://gishub.org/2019_rse>`_ | `source code <https://doi.org/10.6084/m9.figshare.8864921>`_)

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
[![image](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
1414
[![image](https://joss.theoj.org/papers/10.21105/joss.02305/status.svg)](https://joss.theoj.org/papers/10.21105/joss.02305)
1515
[![chat](https://badges.gitter.im/Join%20Chat.svg)](https://matrix.to/#/#geemap:gitter.im)
16+
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/gee-community/geemap/master.svg)](https://results.pre-commit.ci/latest/github/gee-community/geemap/master)
1617

1718
[![logo](https://i.imgur.com/9OOSpDm.png)](https://github.com/gee-community/geemap/blob/master/docs/assets/logo.png)
1819

docs/workshops/.jupytext.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Install jupytext using: conda install jupytext -c conda-forge
2-
# Always pair ipynb notebooks to md files.
2+
# Always pair ipynb notebooks to md files.
33
# formats = "ipynb,md"
44
formats = "ipynb,myst"
55

examples/batch_update.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""This script can do a batch update of notebook examples.
22
"""
33

4-
54
import glob
65
import os
76
import shutil

examples/heroku/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
voila
21
geemap
2+
voila

examples/javascripts/grid.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,60 +9,60 @@ Credits to Gennadii Donchyts.
99
var generateRasterGrid= function(origin, dx, dy, proj) {
1010
var coords = origin.transform(proj).coordinates();
1111
origin = ee.Image.constant(coords.get(0)).addBands(ee.Image.constant(coords.get(1)));
12-
12+
1313
var pixelCoords = ee.Image.pixelCoordinates(proj);
14-
14+
1515
var grid = pixelCoords
1616
.subtract(origin)
1717
.divide([dx, dy]).floor()
1818
.toInt().reduce(ee.Reducer.sum()).bitwiseAnd(1).rename('grid');
19-
19+
2020
var xy = pixelCoords.reproject(proj.translate(coords.get(0), coords.get(1)).scale(dx, dy));
21-
21+
2222
var id = xy.multiply(ee.Image.constant([1, 1000000])).reduce(ee.Reducer.sum()).rename('id');
23-
23+
2424
return grid
2525
.addBands(id)
2626
.addBands(xy);
2727
}
28-
29-
28+
29+
3030
/***
3131
* Generates a regular grid using given bounds, specified as geometry.
3232
*/
3333
var generateGrid = function(xmin, ymin, xmax, ymax, dx, dy, marginx, marginy, opt_proj) {
3434
var proj = opt_proj || 'EPSG:4326';
35-
35+
3636
dx = ee.Number(dx);
3737
dy = ee.Number(dy);
38-
38+
3939
var xx = ee.List.sequence(xmin, ee.Number(xmax).subtract(ee.Number(dx).multiply(0.1)), dx);
4040
var yy = ee.List.sequence(ymin, ee.Number(ymax).subtract(ee.Number(dy).multiply(0.1)), dy);
41-
41+
4242
var cells = xx.map(function(x) {
4343
return yy.map(function(y) {
4444
var x1 = ee.Number(x).subtract(marginx);
4545
var x2 = ee.Number(x).add(ee.Number(dx)).add(marginx);
4646
var y1 = ee.Number(y).subtract(marginy);
4747
var y2 = ee.Number(y).add(ee.Number(dy)).add(marginy);
48-
48+
4949
var coords = ee.List([x1, y1, x2, y2]);
5050
var rect = ee.Algorithms.GeometryConstructors.Rectangle(coords, proj, false);
51-
51+
5252
var nx = x1.add(dx.multiply(0.5)).subtract(xmin).divide(dx).floor();
5353
var ny = y1.add(dy.multiply(0.5)).subtract(ymin).divide(dy).floor();
54-
54+
5555
return ee.Feature(rect)
56-
.set({
56+
.set({
5757
nx: nx.format('%d'),
5858
ny: ny.format('%d'),
5959
});
6060
// .set({cell_id: x1.format('%.3f').cat('_').cat(y1.format('%.3f')) })
6161
});
6262
}).flatten();
63-
63+
6464
return ee.FeatureCollection(cells);
65-
};
65+
};
6666

6767

6868
var grid_test = function() {

examples/workshops/jupytext.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Install jupytext using: conda install jupytext -c conda-forge
2-
# Always pair ipynb notebooks to md files.
2+
# Always pair ipynb notebooks to md files.
33
# formats = "ipynb,md"
44
formats = "ipynb,myst"
55

geemap/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Console script for geemap."""
2+
23
import sys
34
import click
45

0 commit comments

Comments
 (0)