Skip to content

Commit

Permalink
move configuration into pyproject.toml (#36)
Browse files Browse the repository at this point in the history
* move configuration into `pyproject.toml`

* only test if distance is close (to account for floating point differences)

* exclude Mac OSX + Python 3.10

Co-authored-by: zacharyburnett <[email protected]>
  • Loading branch information
zacharyburnett and zacharyburnett authored Apr 19, 2022
1 parent 78f5ba9 commit 818b0e5
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 148 deletions.
65 changes: 11 additions & 54 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,19 @@ on:
- published

jobs:
build_wheels:
name: build wheel
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
python-version: [ '3.x' ]
steps:
- name: checkout repository
uses: actions/checkout@v2
- name: install Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: load cached Python installation
id: cache
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: lint-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'setup.*') }}
- name: build wheel
run: pip wheel . -w dist --no-deps
- name: save wheel
uses: actions/upload-artifact@v2
with:
name: build
path: ./dist/*.whl
build_sdist:
name: package source
publish:
name: publish package to PyPI
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v2
- name: install Python
uses: actions/setup-python@v2
- name: install dependencies
- name: install Poetry
uses: abatilo/actions-poetry@v2.1.3
- name: install Dunamai
run: pip install dunamai
- name: package source
run: python setup.py sdist
- name: save source package
uses: actions/upload-artifact@v2
with:
name: build
path: ./dist/*.tar.gz
upload_pypi:
name: publish to PyPI
needs: [ build_wheels, build_sdist ]
runs-on: ubuntu-latest
steps:
- name: retrieve wheel(s) and source
uses: actions/download-artifact@v2
with:
name: build
path: dist
- name: upload wheel(s) and source
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
- name: extract version from VCS
run: poetry version $(dunamai from any)
- name: build wheel and source
run: poetry build
- name: upload wheel and source
run: poetry publish --username __token__ --password ${{ secrets.PYPI_TOKEN }}
56 changes: 46 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
name: tests

on: [ push ]
on:
push:
branches:
- main
paths:
- '**.py'
- '.github/workflows/tests.yml'
pull_request:
branches:
- main

jobs:
lint:
Expand All @@ -11,22 +20,34 @@ jobs:
uses: actions/checkout@v2
- name: install Python
uses: actions/setup-python@v2
- name: install flake8
run: pip install flake8
- name: load cached Python installation
id: cache
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: lint-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
- name: install linters
run: pip install flake8 oitnb
- 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: lint with oitnb
run: oitnb . --check
test:
needs: lint
name: test
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest ]
python-version: [ '3.6', '3.x' ]
os: [ ubuntu-latest, macos-latest ]
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.x' ]
exclude:
- os: macos-latest
python-version: '3.x'
steps:
- name: clone repository
uses: actions/checkout@v2
Expand All @@ -39,18 +60,33 @@ jobs:
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: test-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'setup.*') }}
key: test-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
- name: install dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: pip install ".[testing]"
- name: run tests
if: matrix.python-version != '3.x' || matrix.os != 'ubuntu-latest'
run: pytest --numprocesses auto
test_with_coverage:
needs: [ lint, test ]
name: test with coverage
runs-on: ubuntu-latest
steps:
- name: clone repository
uses: actions/checkout@v2
- name: install Python
uses: actions/setup-python@v2
- name: load cached Python installation
id: cache
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: test-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
- name: install dependencies
run: pip install ".[testing]"
- name: run tests with coverage
if: matrix.python-version == '3.x' && matrix.os == 'ubuntu-latest'
run: pytest --numprocesses auto --cov . --cov-report xml:coverage.xml
- name: show coverage report
run: coverage report
- name: upload coverage to Codecov
if: matrix.python-version == '3.x' && matrix.os == 'ubuntu-latest'
uses: codecov/[email protected]
with:
token: ${{ secrets.CODECOV_TOKEN }}
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/tests_simple.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: tests

on:
push:
branches-ignore:
- main
paths:
- '**.py'
- '.github/workflows/tests_simple.yml'

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: clone repository
uses: actions/checkout@v2
- name: install Python
uses: actions/setup-python@v2
- name: load cached Python installation
id: cache
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: lint-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
- name: install linters
run: pip install flake8 oitnb
- 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: lint with oitnb
run: oitnb . --check
test:
needs: lint
name: test
runs-on: ubuntu-latest
steps:
- name: clone repository
uses: actions/checkout@v2
- name: install Python
uses: actions/setup-python@v2
- name: load cached Python installation
id: cache
uses: actions/cache@v2
with:
path: ${{ env.pythonLocation }}
key: test-${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}
- name: install dependencies
run: pip install ".[testing]"
- name: run tests
run: pytest --numprocesses auto
47 changes: 44 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,47 @@
[tool.poetry]
name = 'stormevents'
version = '0.0.0'
description = 'Python interfaces for observational data surrounding named storm events'
authors = ['Zach Burnett <[email protected]>']
license = 'GPL-3.0-or-later'
readme = 'README.md'
repository = 'https://github.com/oceanmodeling/StormEvents.git'
documentation = 'https://stormevents.readthedocs.io'

[build-system]
requires = [
"dunamai",
"setuptools",
'poetry-core>=1.0.0',
'poetry-dynamic-versioning',
]
build-backend = "setuptools.build_meta"
build-backend = 'poetry.core.masonry.api'

[tool.poetry-dynamic-versioning]
enable = true

[tool.poetry.dependencies]
python = '^3.6'
beautifulsoup4 = '*'
geopandas = '*'
netcdf4 = '*'
numpy = '*'
python-dateutil = '*'
pandas = '*'
pyproj = '>=2.6'
requests = '*'
shapely = '*'
typepigeon = '>=1.0.5'
xarray = '*'
isort = { version = '*', optional = true }
oitnb = { version = '*', optional = true }
pytest = { version = '*', optional = true }
pytest-cov = { version = '*', optional = true }
pytest-socket = { version = '*', optional = true }
pytest-xdist = { version = '*', optional = true }
m2r2 = { version = '*', optional = true }
sphinx = { version = '*', optional = true }
sphinx-rtd-theme = { version = '*', optional = true }

[tool.poetry.extras]
testing = ['pytest', 'pytest-cov', 'pytest-socket', 'pytest-xdist']
development = ['isort', 'oitnb']
documentation = ['m2r2', 'sphinx', 'sphinx-rtd-theme']
42 changes: 0 additions & 42 deletions setup.cfg

This file was deleted.

17 changes: 0 additions & 17 deletions setup.py

This file was deleted.

9 changes: 5 additions & 4 deletions tests/test_nhc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from copy import copy
from datetime import timedelta
import sys

import numpy
import pytest
from pytest_socket import SocketBlockedError

Expand Down Expand Up @@ -110,7 +112,7 @@ def test_vortex_track_tracks():

assert len(tracks) == 4
assert len(tracks['OFCL']) == 77
assert len(tracks['OFCL']['20180831T000000']) == 2
assert len(tracks['OFCL']['20180831T000000']) == 13


@pytest.mark.disable_socket
Expand Down Expand Up @@ -160,13 +162,12 @@ def test_vortex_track_to_file():
check_reference_directory(output_directory, reference_directory)


@pytest.mark.skip
def test_vortex_track_distances():
track_1 = VortexTrack.from_storm_name('florence', 2018)
track_2 = VortexTrack.from_storm_name('florence', 2018, file_deck='a', advisories=['OFCL'])

assert track_1.distances['BEST']['20180830T060000'] == 8725961.838567913
assert track_2.distances['OFCL']['20180831T000000'] == 15490.033837939689
assert numpy.isclose(track_1.distances['BEST']['20180830T060000'], 8725961.838567913)
assert numpy.isclose(track_2.distances['OFCL']['20180831T000000'], 8882602.389540724)


def test_vortex_track_recompute_velocity():
Expand Down
Loading

0 comments on commit 818b0e5

Please sign in to comment.