Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
68646c2
Add uv-lock to pre-commit hooks
peanutfun Apr 30, 2026
017b804
Update dependency groups and add uv.lock
peanutfun Apr 30, 2026
7f1f80e
Update GitHub actions and readthedocs config
peanutfun Apr 30, 2026
dd0b8f3
ci: Fix setup-uv version
peanutfun Apr 30, 2026
8f22d94
readthedocs: Install libgdal via APT
peanutfun Apr 30, 2026
3af8041
Invoke uv via Makefile
peanutfun Apr 30, 2026
f95a1bc
rtd: Use latest Ubuntu LTS
peanutfun Apr 30, 2026
9a43de2
rtd: Try conda again
peanutfun Apr 30, 2026
5bb73b1
Require pandas <3.0
peanutfun Apr 30, 2026
3cd2b03
pre-commit: Add hook exporting doc requirements
peanutfun Apr 30, 2026
4bf46e2
rtd: Use exported requirements.txt for installation
peanutfun Apr 30, 2026
443aa67
rtd: Add environment file for docs referencing requirements
peanutfun Apr 30, 2026
dc893e6
Move doc environment file
peanutfun Apr 30, 2026
9195a68
rtd: Fix file path
peanutfun Apr 30, 2026
6732de6
rtd: Add Python version to conda environment
peanutfun Apr 30, 2026
9db855c
Add numpy as extra to gdal dependency
peanutfun Jun 3, 2026
caa8c9a
Install openssl in base conda image
peanutfun Jun 3, 2026
f2574bd
Try GDAL v3.13
peanutfun Jun 3, 2026
f64dfba
Avoid GDAL binaries
peanutfun Jun 3, 2026
ccda0fe
uv: Use non-managed Python, try to build gdal and rasterio
peanutfun Jun 4, 2026
e896359
ci: Install Python with micromamba
peanutfun Jun 4, 2026
6413b88
Use rasterio instead of gdal for file reading
peanutfun Jun 5, 2026
7314c01
Remove gdal from dependencies
peanutfun Jun 5, 2026
8f728bc
ci: Stop using mamba, install make
peanutfun Jun 5, 2026
231491d
ci: Fix action version
peanutfun Jun 5, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,19 @@ jobs:
id: date
run: echo "date=$(date +%Y-%m-%d)" >> "${GITHUB_OUTPUT}"
-
name: Create Environment with Mamba
uses: mamba-org/setup-micromamba@v1
name: Install make
uses: awalsh128/cache-apt-pkgs-action@v1
with:
environment-name: climada_env_${{ matrix.python-version }}
environment-file: requirements/env_climada.yml
create-args: >-
python=${{ matrix.python-version }}
make
# Persist environment for branch, Python version, single day
cache-environment-key: env-${{ github.ref }}-${{ matrix.python-version }}-${{ steps.date.outputs.date }}
packages: make
-
name: Install CLIMADA
name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
python-version: ${{ matrix.python-version }}
-
name: Install dependencies
run: |
python -m pip install "./[dev]"
uv sync --locked --dev
-
name: Run Unit Tests
run: |
Expand Down
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,14 @@ repos:
rev: '24.4.2'
hooks:
- id: black-jupyter

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.11.7
hooks:
- id: uv-lock
- id: uv-export
args: [
--frozen, --no-hashes, --quiet, --group=doc,
--output-file=doc/requirements.txt
]
files: (^uv\.lock|doc/requirements\.txt$)
18 changes: 3 additions & 15 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,12 @@ sphinx:
configuration: doc/conf.py

build:
os: "ubuntu-22.04"
os: "ubuntu-26.04"
tools:
python: "mambaforge-4.10"

# Append fixed Python version to requirements
jobs:
pre_create_environment:
- echo " - python=3.11" >> requirements/env_climada.yml
python: "miniforge3-25.11"

conda:
environment: requirements/env_climada.yml

python:
install:
- method: pip
path: .
extra_requirements:
- doc
environment: env-docs.yml

formats:
- pdf
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# test, coverage and lint
###

PRE_CMD = uv run --
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PRE_CMD = uv run --
UV_RUN = uv run --


PYTEST_JUNIT_ARGS = --junitxml=tests_xml/tests.xml

PYTEST_COV_ARGS = \
Expand All @@ -16,32 +18,32 @@ help: ## Use one of the following instructions:

.PHONY : lint
lint : ## Static code analysis with Pylint
pylint -ry climada > pylint.log || true
$(PRE_CMD) pylint -ry climada > pylint.log || true

.PHONY : unit_test
unit_test : ## Unit tests execution with coverage and xml reports
pytest $(PYTEST_ARGS) --ignore=climada/test climada/
$(PRE_CMD) pytest $(PYTEST_ARGS) --ignore=climada/test climada/

.PHONY : install_test
install_test : ## Test installation was successful
pytest $(PYTEST_JUNIT_ARGS) --pyargs climada.engine.test.test_cost_benefit \
$(PRE_CMD) pytest $(PYTEST_JUNIT_ARGS) --pyargs climada.engine.test.test_cost_benefit \
climada.engine.test.test_impact

.PHONY : data_test
data_test : ## Test data APIs
pytest $(PYTEST_JUNIT_ARGS) script/jenkins/test_data_api.py
$(PRE_CMD) pytest $(PYTEST_JUNIT_ARGS) script/jenkins/test_data_api.py

.PHONY : notebook_test
notebook_test : ## Test notebooks in doc/tutorial
pytest $(PYTEST_JUNIT_ARGS) script/jenkins/test_notebooks.py
$(PRE_CMD) pytest $(PYTEST_JUNIT_ARGS) script/jenkins/test_notebooks.py

.PHONY : integ_test
integ_test : ## Integration tests execution with xml reports
pytest $(PYTEST_ARGS) climada/test/
$(PRE_CMD) pytest $(PYTEST_ARGS) climada/test/

.PHONY : test
test : ## Unit and integration tests execution with coverage and xml reports
pytest $(PYTEST_ARGS) climada/
$(PRE_CMD) pytest $(PYTEST_ARGS) climada/

.PHONY : ci-clean
ci-clean :
Expand Down
10 changes: 3 additions & 7 deletions climada/entity/exposures/litpop/nightlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import rasterio
import scipy.sparse as sparse
from affine import Affine
from osgeo import gdal
from PIL import Image
from shapefile import Shape

Expand Down Expand Up @@ -479,7 +478,7 @@ def load_nightlight_nasa(bounds, req_files, year):
continue
extent = np.int64(np.clip(extent, 0, tile_size[None] - 1))
# pylint: disable=unsubscriptable-object
im_nl, _ = read_bm_file(SYSTEM_DIR, fname % (year))
im_nl = read_bm_file(SYSTEM_DIR, fname % (year))
im_nl = np.flipud(im_nl)
im_nl = sparse.csc.csc_matrix(im_nl)
im_nl = im_nl[extent[0, 0] : extent[1, 0] + 1, extent[0, 1] : extent[1, 1] + 1]
Expand Down Expand Up @@ -512,18 +511,15 @@ def read_bm_file(bm_path, filename):
-------
arr1 : array
Raw BM data
curr_file : gdal GeoTiff File
Additional info from which coordinates can be calculated.
"""
path = Path(bm_path, filename)
LOGGER.debug("Importing%s.", path)
if not path.exists():
raise FileNotFoundError(
"Invalid path: check that the path to BlackMarble file is correct."
)
curr_file = gdal.Open(str(path))
arr1 = curr_file.GetRasterBand(1).ReadAsArray()
return arr1, curr_file
curr_file = rasterio.open(path)
return curr_file.read(1)


def unzip_tif_to_py(file_gz):
Expand Down
10 changes: 1 addition & 9 deletions climada/test/test_nightlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import affine
import numpy as np
import scipy.sparse as sparse
from osgeo import gdal
from PIL import Image
from shapely.geometry import Polygon

Expand Down Expand Up @@ -124,18 +123,11 @@ def test_read_bm_files(self):
with self.assertLogs(
"climada.entity.exposures.litpop.nightlight", level="DEBUG"
) as cm:
arr1, curr_file = nightlight.read_bm_file(
bm_path=temp_dir.name, filename=filename
)
arr1 = nightlight.read_bm_file(bm_path=temp_dir.name, filename=filename)
self.assertIn("Importing" + temp_dir.name, cm.output[0])

# Check outputs are a np.array and a gdal DataSet and band 1 is selected
self.assertIsInstance(arr1, np.ndarray)
self.assertIsInstance(curr_file, gdal.Dataset)
self.assertEqual(curr_file.GetRasterBand(1).DataType, 1)

# Release dataset, so the GC can close the file
curr_file = None

# Check that the right exception is raised
with self.assertRaises(FileNotFoundError) as cm:
Expand Down
Loading
Loading