Skip to content

Commit

Permalink
Merge pull request #201 from munterfi/feature/update-python
Browse files Browse the repository at this point in the history
Update to Python 3.11 and new numba version
  • Loading branch information
munterfi authored Dec 5, 2023
2 parents a025a3e + c9c93c8 commit 7688f29
Show file tree
Hide file tree
Showing 11 changed files with 1,020 additions and 1,026 deletions.
84 changes: 42 additions & 42 deletions .github/workflows/gdal-stable-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,47 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.11"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt-get update
sudo apt-get update
sudo apt-get install gdal-bin
sudo apt-get install libgdal-dev
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Set up cache
uses: actions/cache@v1
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
# Pip install without GDAL
poetry export -f requirements.txt --dev --without-hashes | grep -v gdal > requirements.txt
python3 -m pip install -r requirements.txt
# GDAL
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
python3 -m pip install --upgrade pip
python3 -m pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version`
- name: Run checks
run: |
pytest --cov=glacier_flow_model
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
sudo add-apt-repository ppa:ubuntugis/ppa && sudo apt-get update
sudo apt-get update
sudo apt-get install gdal-bin
sudo apt-get install libgdal-dev
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Set up cache
uses: actions/cache@v1
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
# Pip install without GDAL
poetry export -f requirements.txt --dev --without-hashes | grep -v gdal > requirements.txt
python3 -m pip install -r requirements.txt
# GDAL
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
python3 -m pip install --upgrade pip
python3 -m pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version`
- name: Run checks
run: |
pytest --cov=glacier_flow_model
82 changes: 41 additions & 41 deletions .github/workflows/gdal-unstable-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,46 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.11"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable && sudo apt-get update
sudo apt-get install gdal-bin
sudo apt-get install libgdal-dev
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Set up cache
uses: actions/cache@v1
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
# Pip install without GDAL
poetry export -f requirements.txt --dev --without-hashes | grep -v gdal > requirements.txt
python3 -m pip install -r requirements.txt
# GDAL
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
python3 -m pip install --upgrade pip
python3 -m pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version`
- name: Run checks
run: |
pytest --cov=glacier_flow_model
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable && sudo apt-get update
sudo apt-get install gdal-bin
sudo apt-get install libgdal-dev
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Set up cache
uses: actions/cache@v1
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
# Pip install without GDAL
poetry export -f requirements.txt --dev --without-hashes | grep -v gdal > requirements.txt
python3 -m pip install -r requirements.txt
# GDAL
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
python3 -m pip install --upgrade pip
python3 -m pip install --global-option=build_ext --global-option="-I/usr/include/gdal" GDAL==`gdal-config --version`
- name: Run checks
run: |
pytest --cov=glacier_flow_model
74 changes: 37 additions & 37 deletions .github/workflows/package-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.11"]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
brew install gdal
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Set up cache
uses: actions/cache@v1
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install
- name: Run checks
run: |
poetry run flake8 glacier_flow_model tests --count
poetry run mypy .
poetry run pytest --cov=glacier_flow_model
cd docs && poetry run make html && cd ..
- name: Upload coverage reports to Codecov
run: |
poetry run codecov
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install system dependencies
run: |
brew install gdal
- name: Install poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "${HOME}/.local/bin" >> $GITHUB_PATH
- name: Set up cache
uses: actions/cache@v1
with:
path: .venv
key: venv-${{ matrix.python-version }}-${{ hashFiles('poetry.lock') }}

- name: Install dependencies
run: |
poetry config virtualenvs.in-project true
poetry install
- name: Run checks
run: |
poetry run flake8 glacier_flow_model tests --count
poetry run mypy .
poetry run pytest --cov=glacier_flow_model
cd docs && poetry run make html && cd ..
- name: Upload coverage reports to Codecov
run: |
poetry run codecov
2 changes: 1 addition & 1 deletion .github/workflows/package-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.11"]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 2 additions & 2 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ sphinx:

# Use mamba to reduce the memory consumption of the dependency solving process.
build:
os: "ubuntu-20.04"
os: "ubuntu-22.04"
tools:
python: "mambaforge-4.10"
python: "mambaforge-22.9"

# Conda environment
conda:
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ Changelog

This packages uses `semantic versioning <https://semver.org/>`_.

Version 0.4.0
-------------

- Features:
- Update to Python 3.11 and new numba version.
- Bugfixes:
- Solve mypy issues with matplotlib figure.

Version 0.3.2
-------------

Expand Down
10 changes: 0 additions & 10 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,6 @@ def _get_project_meta():
# html_theme = 'sphinx_rtd_theme'
html_theme = "pydata_sphinx_theme"

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
"external_links": [
{"name": "github_url", "url": "https://github.com/munterfi/glacier-flow-model"},
{"name": "twitter_url", "url": "https://twitter.com/munterfi1"},
]
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
Expand Down
12 changes: 6 additions & 6 deletions glacier_flow_model/data/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import importlib.resources as resources
from logging import getLogger

from rasterio import open
from rasterio import open as open_raster
from rasterio import DatasetReader

LOG = getLogger(__name__)
Expand All @@ -21,7 +21,6 @@ def __init__(self) -> None:
Constructor of the PkgDataAccess class.
"""
pass

@staticmethod
def locate_dem() -> str:
Expand All @@ -34,9 +33,10 @@ def locate_dem() -> str:
The path to the file on the system.
"""
with resources.path("glacier_flow_model.data", "aletsch.tif") as file_path:
LOG.info("Example DEM at '%s' ...", file_path)
return str(file_path)
data_folder = resources.files("glacier_flow_model.data")
file_path = data_folder / "aletsch.tif"
LOG.info("Example DEM at '%s' ...", file_path)
return str(file_path)

@staticmethod
def load_dem() -> DatasetReader:
Expand All @@ -51,5 +51,5 @@ def load_dem() -> DatasetReader:
"""
file_path = PkgDataAccess.locate_dem()
LOG.info("Reading DEM from '%s' ...", file_path)
dem = open(file_path)
dem = open_raster(file_path)
return dem
Loading

0 comments on commit 7688f29

Please sign in to comment.