Skip to content

Commit

Permalink
Merge pull request #108 from OpenWaterAnalytics/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
karosc authored Jan 25, 2023
2 parents 443c834 + 37ce646 commit 777701d
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 66 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/conda-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Conda Tests

on:
workflow_run:
workflows: ["Build Wheels"]
types:
- completed


jobs:
test_conda_build:
name: Conda wheel test mac
runs-on: macos-latest
defaults:
run:
shell: bash -l {0}

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: true

- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
channels: conda-forge
# Python 3.9 does not support all libs we need in swmm-python
python-version: 3.8

- name: Install required system packages
run: brew install swig ninja

- name: Install requirements
run: |
cd swmm-toolkit
conda create -n test-env pip
conda activate test-env
pip install -r build-requirements.txt
python setup.py bdist_wheel
conda deactivate
- name: Test wheel
run: |
cd swmm-toolkit
conda activate test-env
pip install -r test-requirements.txt
python -m pip install --no-index --find-links=./dist swmm_toolkit
pytest
conda deactivate
43 changes: 3 additions & 40 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build Wheels
on: [push, pull_request]

env:
DOCKER_IMAGE: dockcross/manylinux2014-x64
DOCKER_IMAGE: dockcross/manylinux2014-x64:latest


jobs:
Expand Down Expand Up @@ -33,43 +33,6 @@ jobs:
with:
path: nrtest-swmm/dist/*.whl

test_conda_build:
name: Conda wheel test mac
runs-on: macos-latest
defaults:
run:
shell: bash -l {0}

steps:
- name: Checkout repo
uses: actions/checkout@v2
with:
submodules: true

- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
channels: conda-forge
# Python 3.9 does not support all libs we need in swmm-python
python-version: 3.8

- name: Install required system packages
run: brew install swig ninja

- name: Install requirements
run: |
cd swmm-toolkit
conda activate test
conda install --yes --file build-requirements.txt
python setup.py bdist_wheel
- name: Test wheel
run: |
cd swmm-toolkit
conda activate test
conda install --yes --file test-requirements.txt
python -m pip install --no-index --find-links=./dist swmm_toolkit --user
pytest


build_linux_wheels:
Expand Down Expand Up @@ -109,7 +72,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-2022, macos-10.15]
py: ["3.7", "3.8", "3.9", "3.10"]
py: ["3.7", "3.8", "3.9", "3.10", "3.11"]
include:
- os: windows-2022
sys_pkgs: choco install swig
Expand Down Expand Up @@ -150,4 +113,4 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
path: swmm-toolkit/dist/*.whl
path: swmm-toolkit/dist/*.whl
14 changes: 7 additions & 7 deletions nrtest-swmm/nrtest_swmm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
__credits__ = "Colleen Barr, Maurizio Cingi, Mark Gray, David Hall, Bryant McDonnell"
__license__ = "CC0 1.0 Universal"

__version__ = "0.6.0"
__date__ = "May 8, 2020"
__version__ = "0.7.0"
__date__ = "Jul 28, 2021"

__maintainer__ = "Michael E. Tryby"
__email__ = "[email protected]"
Expand Down Expand Up @@ -65,15 +65,15 @@ def swmm_allclose_compare(path_test, path_ref, rtol, atol):
for (test, ref) in zip(ordr.output_generator(path_test),
ordr.output_generator(path_ref)):

if len(test[0]) != len(ref[0]):
raise ValueError('Inconsistent lengths')
# Compare arrays when lengths are unequal by truncating extra elements
length = min(len(test[0]), len(ref[0]))

# Skip over results if they are equal
if (np.array_equal(test[0], ref[0])):
# Skip over results if they are equal to optimize performance
if (np.array_equal(test[0][:length], ref[0][:length])):
continue

else:
np.testing.assert_allclose(test[0], ref[0], rtol, atol)
np.testing.assert_allclose(test[0][:length], ref[0][:length], rtol, atol)

return True

Expand Down
8 changes: 4 additions & 4 deletions nrtest-swmm/scripts/report-diff
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ def _binary_diff(path_test, path_ref, min_cdd):
for (test, ref) in zip(ordr.output_generator(path_test),
ordr.output_generator(path_ref)):

if len(test[0]) != len(ref[0]):
raise ValueError('Inconsistent lengths')
# Compare arrays when lengths are unequal by truncating extra elements
length = min(len(test[0]), len(ref[0]))

# Skip over arrays that are equal
if np.array_equal(test[0], ref[0]):
if np.array_equal(test[0][:length], ref[0][:length]):
continue
else:
lre = _log_relative_error(test[0], ref[0])
lre = _log_relative_error(test[0][:length], ref[0][:length])
idx = np.unravel_index(np.argmin(lre), lre.shape)

if lre[idx] < min_cdd:
Expand Down
6 changes: 3 additions & 3 deletions nrtest-swmm/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
#
# setup.py
#
# Modified on October 17, 2019
#
# Author: Michael E. Tryby
# US EPA - ORD/NRMRL
#
# Modified: Jul 28, 2021
#
# Usage:
# \>python setup.py bdist_wheel
#
Expand All @@ -27,7 +27,7 @@

setup(
name='nrtest-swmm',
version='0.6.0',
version='0.7.0',
description="SWMM extension for nrtest",

author="Michael E. Tryby",
Expand Down
2 changes: 1 addition & 1 deletion swmm-toolkit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cmake_minimum_required (VERSION 3.17)

project(swmm-toolkit
VERSION
0.9.0
0.9.1
)


Expand Down
9 changes: 5 additions & 4 deletions swmm-toolkit/build-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@



setuptools==41.4.0
wheel==0.33.6
scikit-build==0.11.1
cmake==3.21
setuptools == 65.5.1
wheel == 0.38.1
scikit-build == 0.11.1
cmake == 3.21
swig == 4.0.2
3 changes: 2 additions & 1 deletion swmm-toolkit/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def exclude_files(cmake_manifest):

setup(
name = "swmm-toolkit",
version = "0.9.0",
version = "0.9.1",

packages = ["swmm_toolkit", "swmm.toolkit"],
package_dir = package_dir,
Expand Down Expand Up @@ -120,6 +120,7 @@ def exclude_files(cmake_manifest):
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: C",
"Development Status :: 5 - Production/Stable",
]
Expand Down
2 changes: 1 addition & 1 deletion swmm-toolkit/src/swmm/toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
__credits__ = "Colleen Barr, Sam Hatchett"
__license__ = "CC0 1.0 Universal"

__version__ = "0.9.0"
__version__ = "0.9.1"
__date__ = "June 7, 2021"

__maintainer__ = "Michael Tryby"
Expand Down
7 changes: 4 additions & 3 deletions swmm-toolkit/test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@



pytest==7.1.1
numpy==1.21.5
aenum==3.1.11
pytest == 7.1.1
numpy == 1.21.6; python_version == "3.7"
numpy == 1.23.4; python_version >= "3.8"
aenum == 3.1.11
4 changes: 2 additions & 2 deletions swmm-toolkit/tools/build-wheels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ set -e -x


# Install a system package required by our library
sudo yum install -y swig
# sudo yum install -y swig


# Setup and build in swmm-toolkit dir
mkdir -p ./dist
cd swmm-toolkit

# Build wheels
for PYBIN in /opt/python/cp{37,38,39,310}*/bin; do
for PYBIN in /opt/python/cp{37,38,39,310,311}*/bin; do
# Setup python virtual environment for build
${PYBIN}/python -m venv --clear ./build-env
source ./build-env/bin/activate
Expand Down

0 comments on commit 777701d

Please sign in to comment.