Skip to content

Commit

Permalink
Bump GDAL to 3.9.1
Browse files Browse the repository at this point in the history
Fixed test matirx
Changed error handling for GDAL in reverse compatible manner
Fixed unit tests accordingly
  • Loading branch information
botenvouwer committed Jul 18, 2024
1 parent 76f9e12 commit 2cc04be
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 31 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,30 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-24.04] #, ubuntu-22.04, ubuntu-20.04] # no ubuntugis @ ubuntu-24.04
python-version: ['3.11'] #, '3.10', '3.9', '3.8', '3.7'] # , '3.6'] <- 3.6 needs setup.cfg
gdal-version: ['3.8'] #, '3.6.2', '3.4']
os: [ubuntu-24.04, ubuntu-22.04, ubuntu-20.04] # no ubuntugis @ ubuntu-24.04
python-version: ['3.11', '3.10', '3.9', '3.8', '3.7'] # , '3.6'] <- 3.6 needs setup.cfg
gdal-version: ['3.8', '3.6', '3.4']
exclude:
- os: ubuntu-24.04
python-version: '3.8'
python-version: '3.9'
- os: ubuntu-24.04
python-version: '3.7'
- os: ubuntu-24.04
python-version: '3.7'
- os: ubuntu-24.04
gdal-version: '3.6'
- os: ubuntu-24.04
gdal-version: '3.4'
- os: ubuntu-22.04
gdal-version: '3.4'
- os: ubuntu-22.04
gdal-version: '3.8'
- os: ubuntu-20.04
python-version: '3.11'
- os: ubuntu-20.04
gdal-version: '3.6'
- os: ubuntu-20.04
gdal-version: '3.8'
steps:
- name: Checkout 🛎️
uses: actions/checkout@v3
Expand All @@ -43,7 +51,7 @@ jobs:
echo adding ubuntugis stable
sudo apt-add-repository ppa:ubuntugis/ppa
fi
sudo apt-get update || true
sudo apt-get update || true # ignore erros becouse we can not install gdal from `ppa:ubuntugis/ppa` without apt errors
echo available python3-gdal versions: $(apt-cache madison python3-gdal | cut -f2 -d "|" | tr -d " ")
echo available libgdal-dev versions: $(apt-cache madison libgdal-dev | cut -f2 -d "|" | tr -d " ")
export APT_GDAL_VERSION=$(apt-cache madison python3-gdal | grep ${{ matrix.gdal-version }} | head -n1 | cut -f2 -d "|" | tr -d " ")
Expand Down
5 changes: 1 addition & 4 deletions geopackage_validator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,9 @@

from pathlib import Path
import json
from time import sleep

import yaml

from typing import Callable, Optional

try:
from osgeo import ogr, osr, gdal

Expand Down Expand Up @@ -64,7 +61,7 @@ def silence_gdal():
try:
dataset = driver.Open(filename, 0)
except Exception as e:
error_handler(gdal.CE_Fatal, 0, e.args[0])
error_handler(gdal.CE_Failure, 0, e.args[0])

if dataset is not None:
dataset.silence_gdal = silence_gdal
Expand Down
1 change: 0 additions & 1 deletion geopackage_validator/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging
import sys
import traceback
from time import sleep

from osgeo import gdal

Expand Down
25 changes: 9 additions & 16 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from osgeo import gdal

from geopackage_validator.utils import (
open_dataset,
dataset_geometry_tables,
Expand Down Expand Up @@ -53,14 +55,12 @@ def gdal_error_handler(err_class, err_num, error):


def do_something_with_error_gdal(dataset):
validations = dataset.ExecuteSQL('select rtreecheck("rtree_table_geom");')
dataset.ReleaseResultSet(validations)
gdal.Error(gdal.CE_Warning, 9999, "test warning message")


def do_something_silenced_gdal(dataset):
with dataset.silence_gdal():
validations = dataset.ExecuteSQL('select rtreecheck("rtree_table_geom");')
dataset.ReleaseResultSet(validations)
gdal.Error(gdal.CE_Warning, 9999, "test warning message")


def test_silence_between_gdal_errors():
Expand All @@ -73,16 +73,9 @@ def gdal_error_handler(err_class, err_num, error):

dataset = open_dataset("tests/data/test_gdal_error.gpkg", gdal_error_handler)

# Since GDAL 3.7 this test will not work because these errors are thrown through the try except clause
try:
do_something_with_error_gdal(dataset)
do_something_silenced_gdal(dataset)
do_something_with_error_gdal(dataset)
except RuntimeError as e:
results.append("GDAL_TRY_ERROR")
do_something_with_error_gdal(dataset)
do_something_silenced_gdal(dataset)
do_something_with_error_gdal(dataset)

if len(results) == 1:
assert results == ["GDAL_TRY_ERROR"]
else:
assert len(results) == 2
assert results == ["GDAL_ERROR", "GDAL_ERROR"]
assert len(results) == 2
assert results == ["GDAL_ERROR", "GDAL_ERROR"]
5 changes: 0 additions & 5 deletions tests/test_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,9 @@ def test_validate_all_validations_no_error():

def test_validate_all_validations_with_broken_gpkg_throws_gdal_error():

# try:
results, validations_executed, success = validate(
gpkg_path="tests/data/test_broken_geopackage.gpkg", validations="ALL"
)
# except Exception:
# print('verwachte fout')
# else:
# print('foute fout')

assert len(results) == 1
print(results)
Expand Down

0 comments on commit 2cc04be

Please sign in to comment.