Skip to content

Commit

Permalink
Store Python 3.7 deps in separate files, use rasterio/fiona Windows w…
Browse files Browse the repository at this point in the history
…heels (microsoft#647)

* Store Python 3.7 deps in separate files, use rasterio/fiona Windows wheels

* Fix fiona 1.9 warning

* Fix import error

* Try again

* Expand obj kwargs

* Fiona still support Python 3.7

* Investigate segfaults

* Undo last commit
  • Loading branch information
adamjstewart authored Jul 4, 2022
1 parent 374be57 commit f8930f7
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 39 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,23 @@ jobs:
python-version: ${{ matrix.python-version }}
channels: conda-forge
channel-priority: strict
if: ${{ runner.os == 'Windows' }}
if: ${{ runner.os == 'Windows' && matrix.python-version == '3.7' }}
- name: Install conda dependencies (Windows)
run: |
conda install 'fiona==1.8.21' 'rasterio==1.2.10'
conda install 'rasterio==1.2.10'
conda list
conda info
if: ${{ runner.os == 'Windows' }}
- name: Install pip dependencies
if: ${{ runner.os == 'Windows' && matrix.python-version == '3.7' }}
- name: Install pip dependencies (3.8+)
run: |
pip install -r requirements/required.txt -r requirements/datasets.txt -r requirements/tests.txt
pip list
if: ${{ matrix.python-version != '3.7' }}
- name: Install pip dependencies (3.7)
run: |
pip install -r requirements/required.old -r requirements/datasets.old -r requirements/tests.txt
pip list
if: ${{ matrix.python-version == '3.7' }}
- name: Run pytest checks
run: pytest --cov=torchgeo --cov-report=xml
- name: Report coverage
Expand All @@ -85,7 +91,7 @@ jobs:
- name: Install pip dependencies
run: |
pip install cython numpy==1.17.2 # needed by pycocotools
pip install -r requirements/min
pip install -r requirements/min.old
pip list
- name: Run pytest checks
run: pytest --cov=torchgeo --cov-report=xml
Expand Down
9 changes: 9 additions & 0 deletions requirements/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This directory contains several files that document the versions of our dependencies used in CI. These are not hard requirements for using TorchGeo.

### Managed by dependabot

All files with a `.txt` extension are managed by dependabot and should not be manually edited unless you need to add or remove a dependency.

### Not managed by dependabot

All files with a `.old` extension are not managed by dependabot. They document the minimum version of our dependencies that we support, or older versions required for versions of Python that the numpy ecosystem no longer supports. See [NEP-29](https://numpy.org/neps/nep-0029-deprecation_policy.html) for more information on the numpy deprecation timeline. See https://github.com/dependabot/dependabot-core/issues/5299 and https://github.com/dependabot/dependabot-core/issues/5300 for why these dependencies have to be in separate files with a different file extension.
14 changes: 14 additions & 0 deletions requirements/datasets.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# datasets
h5py==3.6.0
laspy==2.2.0
open3d==0.14.1;python_version<'3.10'
opencv-python==4.6.0.66
pandas==1.4.3;python_version>='3.8'
pandas==1.3.5;python_version=='3.7'
pycocotools==2.0.4
radiant-mlhub==0.5.1;python_version>='3.8'
radiant-mlhub==0.4.1;python_version=='3.7'
rarfile==4.0
scipy==1.8.1;python_version>='3.8'
scipy==1.7.3;python_version=='3.7'
zipfile-deflate64==0.2.0
7 changes: 0 additions & 7 deletions requirements/datasets.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
# This file is managed by dependabot and should not be manually edited unless you need
# to add or remove a dependency. It documents the version of our dependencies used in
# CI, these are not hard requirements for using TorchGeo.

# datasets
h5py==3.6.0
laspy==2.2.0
open3d==0.14.1;python_version<'3.10'
opencv-python==4.6.0.66
pandas==1.4.3;python_version>='3.8'
pandas==1.3.5;python_version=='3.7'
pycocotools==2.0.4
radiant-mlhub==0.5.1;python_version>='3.8'
radiant-mlhub==0.4.1;python_version=='3.7'
rarfile==4.0
scipy==1.8.1;python_version>='3.8'
scipy==1.7.3;python_version=='3.7'
zipfile-deflate64==0.2.0
4 changes: 0 additions & 4 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# This file is managed by dependabot and should not be manually edited unless you need
# to add or remove a dependency. It documents the version of our dependencies used in
# CI, these are not hard requirements for using TorchGeo.

# docs
ipywidgets==7.7.1
nbsphinx==0.8.9
Expand Down
3 changes: 0 additions & 3 deletions requirements/min → requirements/min.old
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This file is not managed by dependabot. It documents the minimum version of our
# dependencies that is supported.

# setup
setuptools==42.0.0

Expand Down
28 changes: 28 additions & 0 deletions requirements/required.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# setup
setuptools==62.6.0

# install
einops==0.4.1
fiona==1.9a2
kornia==0.6.5
matplotlib==3.5.2
numpy==1.23.0;python_version>='3.8'
numpy==1.21.6;python_version=='3.7'
omegaconf==2.2.2
packaging==21.3
pillow==9.2.0
protobuf==3.20.1
pyproj==3.3.1;python_version>='3.8'
pyproj==3.2.0;python_version=='3.7'
pytorch-lightning==1.6.4
rasterio==1.3b3;python_version>='3.8'
rasterio==1.2.10;python_version=='3.7'
rtree==1.0.0
scikit-learn==1.1.1;python_version>='3.8'
scikit-learn==1.0.2;python_version=='3.7'
segmentation-models-pytorch==0.2.1
shapely==1.8.2
timm==0.4.12
torch==1.12.0
torchmetrics==0.9.2
torchvision==0.13.0
12 changes: 2 additions & 10 deletions requirements/required.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
# This file is managed by dependabot and should not be manually edited unless you need
# to add or remove a dependency. It documents the version of our dependencies used in
# CI, these are not hard requirements for using TorchGeo.

# setup
setuptools==62.6.0

# install
einops==0.4.1
fiona==1.8.21
fiona==1.9a2
kornia==0.6.5
matplotlib==3.5.2
numpy==1.23.0;python_version>='3.8'
numpy==1.21.6;python_version=='3.7'
omegaconf==2.2.2
packaging==21.3
pillow==9.2.0
protobuf==3.20.1
pyproj==3.3.1;python_version>='3.8'
pyproj==3.2.0;python_version=='3.7'
pytorch-lightning==1.6.4
rasterio==1.3b3;python_version=='3.10' and platform_system != 'Windows'
rasterio==1.2.10;python_version<='3.9' or platform_system == 'Windows'
rasterio==1.3b3;python_version>='3.8'
rtree==1.0.0
scikit-learn==1.1.1;python_version>='3.8'
scikit-learn==1.0.2;python_version=='3.7'
segmentation-models-pytorch==0.2.1
shapely==1.8.2
timm==0.4.12
Expand Down
6 changes: 1 addition & 5 deletions requirements/style.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# This file is managed by dependabot and should not be manually edited unless you need
# to add or remove a dependency. It documents the version of our dependencies used in
# CI, these are not hard requirements for using TorchGeo.

# style
black[jupyter]==22.6.0
flake8==4.0.1;python_version=='3.10'
flake8==4.0.1
isort[colors]==5.10.1
pydocstyle[toml]==6.1.1
pyupgrade==2.34.0
4 changes: 0 additions & 4 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# This file is managed by dependabot and should not be manually edited unless you need
# to add or remove a dependency. It documents the version of our dependencies used in
# CI, these are not hard requirements for using TorchGeo.

# tests
mypy==0.961
nbmake==1.3.0
Expand Down
11 changes: 10 additions & 1 deletion torchgeo/datasets/openbuildings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import shapely
import shapely.wkt as wkt
import torch
from packaging.version import parse
from rasterio.crs import CRS
from rtree.index import Index, Property

Expand Down Expand Up @@ -384,8 +385,16 @@ def _wkt_fiona_geom_transform(self, x: str) -> Dict[str, Any]:
"""
x = json.dumps(shapely.geometry.mapping(wkt.loads(x)))
x = json.loads(x.replace("'", '"'))
import fiona

if parse(fiona.__version__) >= parse("1.9a1"):
import fiona.model

geom = fiona.model.Geometry(**x)
else:
geom = x
transformed: Dict[str, Any] = fiona.transform.transform_geom(
self._source_crs.to_dict(), self._crs.to_dict(), x
self._source_crs.to_dict(), self._crs.to_dict(), geom
)
return transformed

Expand Down

0 comments on commit f8930f7

Please sign in to comment.