Skip to content

Commit 9c1aca3

Browse files
lachlangroseLachlan Grosenoellehmcheng
authored
3.2.3 dev (#201)
* fix: remove calls to map2model * fix: remove m2m from deps * fix: use os/python matrix * remove gdal install from test * only run for changes of python files or the workflow * remove conda defaults channel * style: style fixes by ruff and autoformatting by black * remove map2model import * Update linting_and_testing.yml * trying to specify python version in conda install * fix: make shapely imports backwards compatible * points reverted * remove incorrect type hinting * fix: making test work on ALL python. use pathlib and not importlib to find files * fix: multilinestring import * fixing more shapley bugs * add version constraint on shapely * remove . add gdal back * actually add gdal * make workflow runs on all pushes * replace dwithin * fix short_line * fix dependency file path and handle >= version condition in check_all_dependencies * remove gdal from dependencies.txt * change order of dependencies * display gdal owslib versions * fix: specify gdal 3.4.3 for windows python 3.10 * print gdal owslib shapely version * set gdal>=3.6.2 and shapely>=2.0.2 in dependencies.txt * change back to shapely>=2 in dependencies.txt * remove gdal>=3.6.2 from dependencies.txt * windows python 3.10 glda=3.4.3 * add geos version compatibility for shapely.dwithin * add back branch and path restrictions * remove print statements --------- Co-authored-by: Lachlan Grose <[email protected]> Co-authored-by: lachlangrose <[email protected]> Co-authored-by: Noelle Cheng <[email protected]>
1 parent 1af43e4 commit 9c1aca3

File tree

13 files changed

+112
-278
lines changed

13 files changed

+112
-278
lines changed
Lines changed: 43 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
name: Linting and Testing
22

33
on:
4-
[push]
4+
push:
5+
branches:
6+
- master
7+
paths:
8+
- '**.py'
9+
- .github/workflows/linting_and_testing.yml
10+
11+
pull_request:
12+
branches:
13+
- master
14+
paths:
15+
- '**.py'
16+
- .github/workflows/linting_and_testing.yml
17+
workflow_dispatch:
518

619
jobs:
720
linting:
@@ -21,29 +34,42 @@ jobs:
2134

2235

2336
testing:
24-
name: Testing
25-
runs-on: ubuntu-24.04
37+
name: Testing${{ matrix.os }} python ${{ matrix.python-version }}
38+
runs-on: ${{ matrix.os }}
39+
strategy:
40+
fail-fast: false
41+
matrix:
42+
os: ${{ fromJSON(vars.BUILD_OS)}}
43+
python-version: ${{ fromJSON(vars.PYTHON_VERSIONS)}}
44+
2645
steps:
2746
- uses: actions/checkout@v4
28-
- name: Install GDAL
29-
run: |
30-
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
31-
sudo apt-get update
32-
sudo apt-get install -y libgdal-dev gdal-bin
47+
- uses: conda-incubator/setup-miniconda@v3
48+
with:
49+
python-version: ${{ matrix.python-version }}
50+
conda-remove-defaults: "true"
3351

34-
- name: Install dependencies
52+
53+
- name: Install dependencies for windows python 3.10
54+
if: ${{ matrix.os == 'windows-latest' && matrix.python-version == '3.10' }}
3555
run: |
36-
conda update -n base -c defaults conda -y
37-
conda install -n base conda-libmamba-solver -c conda-forge -y
38-
conda install -c conda-forge gdal -y
39-
conda install -c conda-forge -c loop3d --file dependencies.txt -y
40-
conda install pytest -y
56+
conda run -n test conda info
57+
conda run -n test conda install -c loop3d -c conda-forge "gdal=3.4.3" python=${{ matrix.python-version }} -y
58+
conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y
59+
conda run -n test conda install pytest python=${{ matrix.python-version }} -y
4160
61+
- name: Install dependencies for other environments
62+
if: ${{ matrix.os != 'windows-latest' || matrix.python-version != '3.10' }}
63+
run: |
64+
conda run -n test conda info
65+
conda run -n test conda install -c loop3d -c conda-forge gdal python=${{ matrix.python-version }} -y
66+
conda run -n test conda install -c loop3d -c conda-forge --file dependencies.txt python=${{ matrix.python-version }} -y
67+
conda run -n test conda install pytest python=${{ matrix.python-version }} -y
68+
4269
- name: Install map2loop
4370
run: |
44-
python -m pip install .
71+
conda run -n test python -m pip install .
4572
4673
- name: Run tests
4774
run: |
48-
pytest
49-
75+
conda run -n test pytest

dependencies.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
numpy
22
scipy
33
geopandas
4-
shapely
4+
shapely>=2
55
networkx
66
owslib
7-
map2model
87
loopprojectfile==0.2.2
98
beartype
109
pytest

map2loop/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class DependencyChecker:
3030

3131
def __init__(self, package_name, dependency_file="dependencies.txt"):
3232
self.package_name = package_name
33-
self.dependency_file = pathlib.Path(__file__).parent / dependency_file
33+
self.dependency_file = pathlib.Path(__file__).parent.parent / dependency_file
3434
self.required_version = self.get_required_version()
3535
self.installed_version = self.get_installed_version()
3636

@@ -93,7 +93,7 @@ def check_version(self):
9393

9494

9595
def check_all_dependencies(dependency_file="dependencies.txt"):
96-
dependencies_path = pathlib.Path(__file__).parent / dependency_file
96+
dependencies_path = pathlib.Path(__file__).parent.parent / dependency_file
9797
try:
9898
with dependencies_path.open("r") as file:
9999
for line in file:
@@ -103,6 +103,8 @@ def check_all_dependencies(dependency_file="dependencies.txt"):
103103
if line:
104104
if "==" in line:
105105
package_name, _ = line.split("==")
106+
elif ">=" in line:
107+
package_name, _ = line.split(">=")
106108
else:
107109
package_name = line
108110

map2loop/_datasets/geodata_files/load_map2loop_data.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import geopandas
2-
from importlib.resources import files
2+
import map2loop
3+
import pathlib
34
from osgeo import gdal
45
gdal.UseExceptions()
5-
6+
def map2loop_dir(folder)-> pathlib.Path:
7+
path = pathlib.Path(map2loop.__file__).parent
8+
path = path / "_datasets"/"geodata_files"/f'{folder}'
9+
return path
610
def load_hamersley_geology():
711
"""
812
Loads Hamersley geology data from a shapefile
@@ -14,8 +18,9 @@ def load_hamersley_geology():
1418
Returns:
1519
geopandas.GeoDataFrame: The geology data
1620
"""
17-
stream = files("map2loop._datasets.geodata_files.hamersley").joinpath("geology.geojson")
18-
return geopandas.read_file(stream)
21+
22+
path = map2loop_dir('hamersley') / "geology.geojson"
23+
return geopandas.read_file(str(path))
1924

2025

2126
def load_hamersley_structure():
@@ -30,8 +35,8 @@ def load_hamersley_structure():
3035
geopandas.GeoDataFrame: The structure data
3136
"""
3237

33-
path = files("map2loop._datasets.geodata_files.hamersley").joinpath("structure.geojson")
34-
return geopandas.read_file(path)
38+
path = map2loop_dir('hamersley') / "structure.geojson"
39+
return geopandas.read_file(str(path))
3540

3641

3742
def load_hamersley_dtm():
@@ -41,5 +46,5 @@ def load_hamersley_dtm():
4146
Returns:
4247
gdal.Dataset: The DTM data
4348
"""
44-
path = files("map2loop._datasets.geodata_files.hamersley").joinpath("dtm_rp.tif")
45-
return gdal.Open(path)
49+
path = map2loop_dir('hamersley') / "dtm_rp.tif"
50+
return gdal.Open(str(path))

map2loop/data_checks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def check_geology_fields_validity(mapdata) -> tuple[bool, str]:
4141
# 2. Validate geometry
4242
failed, message = validate_geometry(
4343
geodata=geology_data,
44-
expected_geom_types=[shapely.Polygon, shapely.MultiPolygon],
44+
expected_geom_types=[shapely.geometry.Polygon, shapely.geometry.MultiPolygon],
4545
datatype_name="GEOLOGY"
4646
)
4747
if failed:

0 commit comments

Comments
 (0)