Skip to content

Commit

Permalink
run in conda environment
Browse files Browse the repository at this point in the history
  • Loading branch information
dugalh committed Sep 22, 2023
1 parent f0e9aeb commit b44d3f6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 24 deletions.
62 changes: 46 additions & 16 deletions .github/workflows/run-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,63 @@ on:
jobs:
test:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ macos-latest, ubuntu-latest, windows-latest ]
python-version: ['3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
- uses: actions/checkout@v3 # for the test data
- uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
channels: conda-forge
channel-priority: true
activate-environment: test
mamba-version: "*"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest pytest-cov
python -m pip install rasterio "opencv-python-headless<4.8" numpy click tqdm pyyaml
python -m pip list
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
timeout-minutes: 5
mamba info
mamba list
mamba install -c conda-forge rasterio opencv numpy click tqdm pyyaml pytest pytest-cov
mamba list
- name: Run unit tests
run: |
python -m pytest --cov=simple_ortho --cov-report=term-missing --cov-report=xml:coverage.xml ./tests
#jobs:
# test:
# runs-on: ${{ matrix.os }}
# strategy:
# fail-fast: false
# matrix:
# python-version: ['3.8', '3.9', '3.10', '3.11']
# os: [ macos-latest, ubuntu-latest, windows-latest ]
# steps:
# - uses: actions/checkout@v3
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# python -m pip install flake8 pytest pytest-cov
# python -m pip install rasterio "opencv-python-headless<4.8" numpy click tqdm pyyaml
# python -m pip list
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# - name: Test with pytest
# timeout-minutes: 5
# run: |
# python -m pytest --cov=simple_ortho --cov-report=term-missing --cov-report=xml:coverage.xml ./tests
# - name: Upload coverage
# uses: codecov/codecov-action@v3
# with:
Expand Down
16 changes: 8 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,31 +298,31 @@ def webmerc_egm2008_crs() -> str:
@pytest.fixture(scope='session')
def rgb_byte_src_file(tmpdir_factory: pytest.TempdirFactory, im_size: Tuple) -> Path:
""" An RGB byte checkerboard image with no CRS. """
src_filename = Path(tmpdir_factory.mktemp('data').join('rgb_byte_src.tif'))
src_filename = Path(tmpdir_factory.mktemp('data')).joinpath('rgb_byte_src.tif')
create_src(src_filename, im_size, dtype='uint8', count=3)
return src_filename


@pytest.fixture(scope='session')
def rgb_float_src_file(tmpdir_factory: pytest.TempdirFactory, im_size: Tuple) -> Path:
""" An RGB float32 checkerboard image with no CRS. """
src_filename = Path(tmpdir_factory.mktemp('data').join('rgb_float_src.tif'))
src_filename = Path(tmpdir_factory.mktemp('data')).joinpath('rgb_float_src.tif')
create_src(src_filename, im_size, dtype='float32', count=3)
return src_filename


@pytest.fixture(scope='session')
def float_src_file(tmpdir_factory: pytest.TempdirFactory, im_size: Tuple) -> Path:
""" A single band float64 checkerboard image with no CRS. """
src_filename = Path(tmpdir_factory.mktemp('data').join('float_src.tif'))
src_filename = Path(tmpdir_factory.mktemp('data')).joinpath('float_src.tif')
create_src(src_filename, im_size, dtype='float32', count=1)
return src_filename


@pytest.fixture(scope='session')
def rgb_byte_utm34n_src_file(tmpdir_factory: pytest.TempdirFactory, pinhole_camera, utm34n_crs) -> Path:
""" An RGB byte checkerboard image with UTM zone 34N CRS and bounds 100m below `pinhole_camera`. """
src_filename = Path(tmpdir_factory.mktemp('data').join('rgb_byte_src.tif'))
src_filename = Path(tmpdir_factory.mktemp('data')).joinpath('rgb_byte_src.tif')
create_src(src_filename, pinhole_camera._im_size, dtype='uint8', count=3, camera=pinhole_camera, crs=utm34n_crs)
return src_filename

Expand All @@ -333,7 +333,7 @@ def float_utm34n_dem_file(tmpdir_factory: pytest.TempdirFactory, pinhole_camera,
A 2 band float DEM file in UTM zone 34N with no vertical datum.
Band 1 is a sinusoidal surface, and band 2, a planar surface.
"""
filename = Path(tmpdir_factory.mktemp('data').join('float_utm34n_dem.tif'))
filename = Path(tmpdir_factory.mktemp('data')).joinpath('float_utm34n_dem.tif')
create_dem(filename, pinhole_camera, utm34n_crs, resolution=_dem_resolution, dtype='float32')
return filename

Expand All @@ -344,7 +344,7 @@ def float_utm34n_wgs84_dem_file(tmpdir_factory: pytest.TempdirFactory, pinhole_c
A 2 band float DEM file in UTM zone 34N with WGS84 ellipsoid vertical datum.
Band 1 is a sinusoidal surface, and band 2, a planar surface.
"""
filename = Path(tmpdir_factory.mktemp('data').join('float_utm34n_wgs84_dem.tif'))
filename = Path(tmpdir_factory.mktemp('data')).joinpath('float_utm34n_wgs84_dem.tif')
create_dem(filename, pinhole_camera, utm34n_wgs84_crs, resolution=_dem_resolution, dtype='float32')
return filename

Expand All @@ -355,7 +355,7 @@ def float_utm34n_egm96_dem_file(tmpdir_factory: pytest.TempdirFactory, pinhole_c
A 2 band float DEM file in UTM zone 34N with EGM96 geoid vertical datum.
Band 1 is a sinusoidal surface, and band 2, a planar surface.
"""
filename = Path(tmpdir_factory.mktemp('data').join('float_utm34n_egm96_dem.tif'))
filename = Path(tmpdir_factory.mktemp('data')).joinpath('float_utm34n_egm96_dem.tif')
create_dem(filename, pinhole_camera, utm34n_egm96_crs, resolution=_dem_resolution, dtype='float32')
return filename

Expand All @@ -366,7 +366,7 @@ def float_wgs84_wgs84_dem_file(tmpdir_factory: pytest.TempdirFactory, pinhole_ca
A 2 band float DEM file in WGS84 with WGS84 ellipsoid vertical datum.
Band 1 is a sinusoidal surface, and band 2, a planar surface.
"""
filename = Path(tmpdir_factory.mktemp('data').join('float_wgs84_wgs84_dem.tif'))
filename = Path(tmpdir_factory.mktemp('data')).joinpath('float_wgs84_wgs84_dem.tif')
create_dem(
filename, pinhole_camera, utm34n_wgs84_crs, resolution=_dem_resolution, dtype='float32',
dem_crs='EPSG:4326+4326'
Expand Down

0 comments on commit b44d3f6

Please sign in to comment.