Skip to content

Commit 42e3081

Browse files
committed
Merge branch 'main' of github.com:geo-engine/geoengine-python into skip-empty-times
2 parents 1f00be3 + 40f799b commit 42e3081

Some content is hidden

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

57 files changed

+5654
-6354
lines changed

.github/.backend_git_ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
main

.github/workflows/ci.yml

Lines changed: 14 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -3,98 +3,34 @@ name: CI
33
on:
44
pull_request:
55
merge_group:
6+
# Creates a coverage of the main branch
7+
push:
8+
branches:
9+
- main
610
# Allows you to run this workflow manually from the Actions tab
711
workflow_dispatch:
812

913
jobs:
1014
check:
11-
runs-on: ubuntu-22.04
15+
uses: geo-engine/geoengine-python/.github/workflows/test-python.yml@main
1216

1317
strategy:
1418
fail-fast: false
1519
matrix:
1620
# use all supported versions from https://devguide.python.org/versions/
1721
python-version: ["3.9", "3.10", "3.11", "3.12"]
1822

19-
steps:
20-
- uses: actions/checkout@v3
21-
- name: APT update
22-
run: sudo apt-get update
23-
- name: Install system dependencies
24-
run: sudo apt-get install libgeos-dev libproj-dev
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: ${{ matrix.python-version }}
29-
- name: Install build dependencies
30-
run: |
31-
python -m pip install --upgrade pip
32-
pip install -e .
33-
pip install -e .[dev]
34-
- name: Check Formatting
35-
run: |
36-
python -m pycodestyle
37-
- name: Lint code
38-
run: |
39-
python -m pylint geoengine
40-
- name: Type-check code
41-
run: |
42-
python -m mypy geoengine
43-
- name: Build
44-
run: python -m build .
45-
- name: Install test dependencies
46-
run: |
47-
pip install -e .[test]
48-
- name: Lint tests
49-
run: |
50-
python -m pylint tests
51-
- name: Type-check tests
52-
run: |
53-
python -m mypy tests
54-
- name: Test
55-
run: pytest
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
use-uv: false
26+
coverage: false
5627

5728
# Checks the library using minimum version resolution
5829
# `uv` has this feature built-in, c.f. https://github.com/astral-sh/uv
5930
check-min-version:
60-
runs-on: ubuntu-22.04
31+
uses: geo-engine/geoengine-python/.github/workflows/test-python.yml@main
6132

62-
env:
63-
# use minimum supported versions from https://devguide.python.org/versions/
64-
python-version: "3.9"
65-
# lowest compatible versions for all direct dependencies
66-
# cf., https://github.com/astral-sh/uv#resolution-strategy
67-
resolution: "lowest-direct"
68-
69-
steps:
70-
- uses: actions/checkout@v3
71-
- name: APT update
72-
run: sudo apt-get update
73-
- name: Install system dependencies
74-
run: sudo apt-get install libgeos-dev libproj-dev
75-
- name: Set up Python ${{ env.python-version }}
76-
uses: actions/setup-python@v4
77-
with:
78-
python-version: ${{ env.python-version }}
79-
- name: Install build dependencies
80-
run: |
81-
python -m pip install --upgrade pip
82-
pip install uv
83-
84-
uv venv
85-
source .venv/bin/activate
86-
87-
uv pip install --resolution=${{ env.resolution}} -e .
88-
uv pip install --resolution=${{ env.resolution}} -e .[dev]
89-
- name: Build
90-
run: |
91-
source .venv/bin/activate
92-
python -m build .
93-
- name: Install test dependencies
94-
run: |
95-
source .venv/bin/activate
96-
uv pip install --resolution=${{ env.resolution}} -e .[test]
97-
- name: Test
98-
run: |
99-
source .venv/bin/activate
100-
pytest
33+
with:
34+
python-version: 3.9
35+
use-uv: true
36+
coverage: true

.github/workflows/test-python.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Test Python Library
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python-version:
7+
type: string
8+
required: true
9+
description: 'Python version to use, e.g., "3.9"'
10+
use-uv:
11+
type: boolean
12+
default: false
13+
description: 'Use `uv` for minimum version resolution'
14+
coverage:
15+
type: boolean
16+
default: false
17+
description: 'Generate coverage report'
18+
19+
jobs:
20+
check:
21+
runs-on: ubuntu-22.04
22+
23+
services:
24+
postgres:
25+
image: postgis/postgis
26+
env:
27+
POSTGRES_USER: geoengine
28+
POSTGRES_PASSWORD: geoengine
29+
POSTGRES_DB: geoengine
30+
ports:
31+
- 5432:5432
32+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
33+
34+
defaults:
35+
run:
36+
working-directory: library
37+
38+
steps:
39+
- name: Checkout library code
40+
uses: actions/checkout@v4
41+
with:
42+
path: library
43+
- name: Setup variables
44+
id: vars
45+
run: |
46+
echo "GEOENGINE_VERSION=$(cat .github/.backend_git_ref)" >> $GITHUB_OUTPUT
47+
if ${{ inputs.use-uv }}; then
48+
echo "PIP_INSTALL=uv pip install --resolution=lowest-direct" >> $GITHUB_OUTPUT
49+
echo "VENV_CALL=source .venv/bin/activate" >> $GITHUB_OUTPUT
50+
else
51+
echo "PIP_INSTALL=pip install" >> $GITHUB_OUTPUT
52+
echo "VENV_CALL=" >> $GITHUB_OUTPUT
53+
fi
54+
if ${{ inputs.coverage }}; then
55+
echo "COVERAGE_COMMAND=--cov=geoengine --cov-report=lcov" >> $GITHUB_OUTPUT
56+
else
57+
echo "COVERAGE_COMMAND=" >> $GITHUB_OUTPUT
58+
fi
59+
- name: Checkout Geo Engine code
60+
uses: actions/checkout@v4
61+
with:
62+
repository: geo-engine/geoengine
63+
ref: ${{ steps.vars.outputs.GEOENGINE_VERSION }}
64+
path: backend
65+
- name: Free Disk Space (Ubuntu)
66+
uses: jlumbroso/free-disk-space@main
67+
with:
68+
tool-cache: true
69+
android: true
70+
dotnet: true
71+
haskell: true
72+
large-packages: true
73+
docker-images: true
74+
swap-storage: true
75+
- name: Install lld & GDAL & Protobuf
76+
run: |
77+
sudo apt-get update
78+
sudo apt-get install lld libgdal-dev gdal-bin build-essential clang curl protobuf-compiler libgeos-dev libproj-dev
79+
sudo apt-get clean
80+
export C_INCLUDE_PATH=/usr/include/gdal:$C_INCLUDE_PATH
81+
export CPLUS_INCLUDE_PATH=/usr/include/gdal:$CPLUS_INCLUDE_PATH
82+
sudo ldconfig
83+
- name: Install Rustup
84+
run: |
85+
curl --proto '=https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL "https://sh.rustup.rs" | sh -s -- --profile minimal --default-toolchain none -y
86+
echo "${CARGO_HOME:-$HOME/.cargo}/bin" >> $GITHUB_PATH
87+
- name: Set up Python ${{ inputs.python-version }}
88+
uses: actions/setup-python@v4
89+
with:
90+
python-version: ${{ inputs.python-version }}
91+
- name: Upgrade PIP
92+
run: python -m pip install --upgrade pip
93+
- name: Setup UV and create venv
94+
if: ${{ inputs.use-uv }}
95+
run: |
96+
pip install uv
97+
uv venv
98+
- name: Install build dependencies
99+
run: |
100+
${{ steps.vars.outputs.VENV_CALL }}
101+
${{ steps.vars.outputs.PIP_INSTALL }} -e .[dev]
102+
- name: Check Formatting
103+
run: |
104+
${{ steps.vars.outputs.VENV_CALL }}
105+
python -m pycodestyle
106+
- name: Lint code
107+
run: |
108+
${{ steps.vars.outputs.VENV_CALL }}
109+
python -m pylint geoengine
110+
- name: Type-check code
111+
# mypy seems buggy with uv
112+
if: ${{ !inputs.use-uv }}
113+
run: |
114+
${{ steps.vars.outputs.VENV_CALL }}
115+
python -m mypy geoengine
116+
- name: Build
117+
run: |
118+
${{ steps.vars.outputs.VENV_CALL }}
119+
python -m build .
120+
- name: Install test dependencies
121+
run: |
122+
${{ steps.vars.outputs.VENV_CALL }}
123+
${{ steps.vars.outputs.PIP_INSTALL }} -e .[test]
124+
- name: Lint tests
125+
run: |
126+
${{ steps.vars.outputs.VENV_CALL }}
127+
python -m pylint tests
128+
- name: Type-check tests
129+
# mypy seems buggy with uv
130+
if: ${{ !inputs.use-uv }}
131+
run: |
132+
${{ steps.vars.outputs.VENV_CALL }}
133+
python -m mypy tests
134+
- name: Test
135+
run: |
136+
${{ steps.vars.outputs.VENV_CALL }}
137+
pytest ${{ steps.vars.outputs.COVERAGE_COMMAND }}
138+
env:
139+
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend
140+
GEOENGINE_TEST_BUILD_TYPE: "release"
141+
- name: Upload coverage to Coveralls
142+
if: ${{ inputs.coverage }}
143+
uses: coverallsapp/github-action@v2
144+
with:
145+
base-path: library
146+
- name: Examples
147+
run: |
148+
${{ steps.vars.outputs.VENV_CALL }}
149+
${{ steps.vars.outputs.PIP_INSTALL }} -e .[examples]
150+
python test_all_notebooks.py
151+
env:
152+
GEOENGINE_TEST_CODE_PATH: ${{ github.workspace }}/backend
153+
GEOENGINE_TEST_BUILD_TYPE: "release"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ __pycache__
1414
# Virtual Environments
1515
env
1616
env-*
17+
.venv
1718

1819
# Private files
1920
.pypirc
@@ -23,4 +24,5 @@ env-*
2324
# Downloaded files
2425
examples/raster_download.tif
2526
examples/download
26-
examples/test
27+
examples/test
28+
examples/export_data/test

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Geo Engine Python Package
22

3-
[![CI](https://github.com/geo-engine/geoengine-python/actions/workflows/ci.yml/badge.svg)](https://github.com/geo-engine/geoengine-python/actions/workflows/ci.yml)
3+
[![CI](https://github.com/geo-engine/geoengine-python/actions/workflows/ci.yml/badge.svg?event=merge_group)](https://github.com/geo-engine/geoengine-python/actions/workflows/ci.yml?query=event%3Amerge_group)
4+
[![Coverage Status](https://coveralls.io/repos/github/geo-engine/geoengine-python/badge.svg)](https://coveralls.io/github/geo-engine/geoengine-python)
5+
[![Documentation](https://img.shields.io/badge/documentation-python.docs.geoengine.io-blue)](https://python.docs.geoengine.io/)
46

57
This package allows easy access to Geo Engine functionality from Python environments.
68

@@ -47,6 +49,34 @@ Run tests with:
4749
pytest
4850
```
4951

52+
#### Test instance
53+
54+
You have to set the environment variable `GEOENGINE_TEST_CODE_PATH` to the code folder of the Geo Engine instance you want to test against.
55+
Dotenv is supported, so you can create a `.env` file in the root of the project.
56+
57+
#### Coverage
58+
59+
You can check the coverage with:
60+
61+
```bash
62+
pytest --cov=geoengine
63+
```
64+
65+
### Test examples
66+
67+
You can test the examples with:
68+
69+
```bash
70+
python3 -m pip install -e .[examples]
71+
./test_all_notebooks.py
72+
```
73+
74+
Or you can test a single example with:
75+
76+
```bash
77+
./test_notebook.py examples/ndvi_ports.ipynb
78+
```
79+
5080
## Dependencies
5181

5282
Since we use `cartopy`, you need to have the following system dependencies installed.
@@ -107,7 +137,7 @@ python3 -m mypy tests
107137
Using the config file `mypy.ini`, you can suppress missing stub errors for external libraries.
108138
You can ignore a library by adding two lines to the config file. For example, suppressing matplotlib would look like this:
109139

110-
```
140+
```ini
111141
[mypy-matplotlib.*]
112142
ignore_missing_imports = True
113143

check.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ function echoerr() {
1111
echo "$@" 1>&2;
1212
}
1313

14-
echoerr "Running tests"
15-
16-
pytest
17-
1814
echoerr "Check code style"
1915

2016
python3 -m pycodestyle
@@ -28,3 +24,11 @@ echoerr "Check code with type checker"
2824

2925
python3 -m mypy geoengine
3026
python3 -m mypy tests
27+
28+
echoerr "Running tests"
29+
30+
pytest
31+
32+
echoerr "Running examples"
33+
34+
python3 test_all_notebooks.py

0 commit comments

Comments
 (0)