Skip to content

Commit 31e90fd

Browse files
authored
Merge pull request #40 from MODFLOW-USGS/v0.2.0
Release 0.2.0
2 parents 400780e + 9de3c7f commit 31e90fd

24 files changed

+819
-1411
lines changed

.github/workflows/ci.yml

+48-8
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,58 @@ jobs:
128128
- name: Install modflow executables
129129
uses: modflowpy/install-modflow-action@v1
130130
with:
131-
path: ~/work/modflowapi/modflowapi/autotest
131+
path: ${{ github.workspace }}/autotest
132132
repo: modflow6-nightly-build
133133

134134
- name: Run autotests
135135
working-directory: ./autotest
136136
shell: bash -l {0}
137+
run: pytest -v -n auto -m "not mf6"
138+
139+
autotest_preidm_extensions:
140+
name: modflowapi pre-idm extensions autotests
141+
needs: lint
142+
runs-on: ${{ matrix.os }}
143+
strategy:
144+
fail-fast: false
145+
matrix:
146+
os: [ ubuntu-latest, macos-latest, windows-latest ]
147+
python-version: [ 3.8, 3.9, "3.10", "3.11" ]
148+
defaults:
149+
run:
150+
shell: bash
151+
152+
steps:
153+
# check out repo
154+
- name: Checkout repo
155+
uses: actions/checkout@v3
156+
157+
- name: Setup Python
158+
uses: actions/setup-python@v4
159+
with:
160+
python-version: ${{ matrix.python-version }}
161+
cache: 'pip'
162+
cache-dependency-path: pyproject.toml
163+
164+
- name: Install Python dependencies
137165
run: |
138-
# chmod a+x libmf6*
139-
pytest -n auto -m "not mf6"
140-
166+
python -m pip install --upgrade pip
167+
pip install git+https://[email protected]/Deltares/xmipy@develop
168+
pip install git+https://[email protected]/MODFLOW-USGS/modflow-devtools@develop
169+
pip install .[test]
170+
171+
- name: Install modflow executables
172+
uses: modflowpy/install-modflow-action@v1
173+
with:
174+
path: ${{ github.workspace }}/autotest
175+
repo: executables
176+
tag: "14.0"
177+
178+
- name: Run autotests
179+
working-directory: ./autotest
180+
shell: bash -l {0}
181+
run: pytest -v -n auto -m "not mf6"
182+
141183
autotest_mf6_examples:
142184
name: modflowapi mf6 examples autotests
143185
needs: lint
@@ -173,12 +215,10 @@ jobs:
173215
- name: Install modflow executables
174216
uses: modflowpy/install-modflow-action@v1
175217
with:
176-
path: ~/work/modflowapi/modflowapi/autotest
218+
path: ${{ github.workspace }}/autotest
177219
repo: modflow6-nightly-build
178220

179221
- name: Run autotests
180222
working-directory: ./autotest
181223
shell: bash -l {0}
182-
run: |
183-
# chmod a+x libmf6*
184-
pytest -n auto -m "mf6 and not extensions"
224+
run: pytest -v -n auto -m "mf6 and not extensions"

.github/workflows/release.yml

+207
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- v[0-9]+.[0-9]+.[0-9]+*
7+
release:
8+
types:
9+
- published
10+
jobs:
11+
prep:
12+
name: Prepare release
13+
runs-on: ubuntu-latest
14+
if: ${{ github.event_name == 'push' && github.ref_name != 'main' }}
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
defaults:
19+
run:
20+
shell: bash
21+
steps:
22+
23+
- name: Checkout release branch
24+
uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup Python
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: 3.8
32+
cache: 'pip'
33+
cache-dependency-path: pyproject.toml
34+
35+
- name: Install Python dependencies
36+
run: |
37+
pip install --upgrade pip
38+
pip install build twine
39+
pip install .
40+
pip install ".[lint, test]"
41+
42+
- name: Update version
43+
id: version
44+
run: |
45+
ref="${{ github.ref_name }}"
46+
version="${ref#"v"}"
47+
python scripts/update_version.py -v "$version"
48+
python -c "import modflowapi; print('Version: ', modflowapi.__version__)"
49+
echo "version=$version" >> $GITHUB_OUTPUT
50+
51+
- name: Touch changelog
52+
run: touch HISTORY.md
53+
54+
- name: Generate changelog
55+
id: cliff
56+
uses: orhun/git-cliff-action@v1
57+
with:
58+
config: cliff.toml
59+
args: --verbose --unreleased --tag ${{ steps.version.outputs.version }}
60+
env:
61+
OUTPUT: CHANGELOG.md
62+
63+
- name: Update changelog
64+
run: |
65+
# substitute full group names
66+
sed -i 's/#### Ci/#### Continuous integration/' CHANGELOG.md
67+
sed -i 's/#### Feat/#### New features/' CHANGELOG.md
68+
sed -i 's/#### Fix/#### Bug fixes/' CHANGELOG.md
69+
sed -i 's/#### Refactor/#### Refactoring/' CHANGELOG.md
70+
sed -i 's/#### Test/#### Testing/' CHANGELOG.md
71+
72+
# prepend release changelog to cumulative changelog
73+
clog="HISTORY.md"
74+
temp="temp.md"
75+
echo "$(tail -n +2 $clog)" > $clog
76+
cat CHANGELOG.md $clog > $temp
77+
sudo mv $temp $clog
78+
sed -i '1i # Changelog' $clog
79+
80+
- name: Upload changelog
81+
uses: actions/upload-artifact@v3
82+
with:
83+
name: changelog
84+
path: CHANGELOG.md
85+
86+
- name: Format Python files
87+
run: python scripts/pull_request_prepare.py
88+
89+
- name: Push release branch
90+
env:
91+
GITHUB_TOKEN: ${{ github.token }}
92+
run: |
93+
ver="${{ steps.version.outputs.version }}"
94+
changelog=$(cat CHANGELOG.md | grep -v "### Version $ver")
95+
96+
# remove this release's changelog so we don't commit it
97+
# the changes have already been prepended to HISTORY.md
98+
rm -f CHANGELOG.md
99+
100+
# commit and push changes
101+
git config core.sharedRepository true
102+
git config user.name "github-actions[bot]"
103+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
104+
git add -A
105+
git commit -m "ci(release): set version to ${{ steps.version.outputs.version }}, update changelog"
106+
git push origin "${{ github.ref_name }}"
107+
108+
title="Release $ver"
109+
body='
110+
# Release '$ver'
111+
112+
The release can be approved by merging this pull request into `main`. This will trigger jobs to publish the release to PyPI and reset `develop` from `main`, incrementing the minor version number.
113+
114+
## Changelog
115+
116+
'$changelog'
117+
'
118+
gh pr create -B "main" -H "${{ github.ref_name }}" --title "$title" --draft --body "$body"
119+
120+
release:
121+
name: Draft release
122+
# runs only when changes are merged to main
123+
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
124+
runs-on: ubuntu-latest
125+
permissions:
126+
contents: write
127+
pull-requests: write
128+
steps:
129+
130+
- name: Checkout repo
131+
uses: actions/checkout@v3
132+
with:
133+
ref: main
134+
135+
- name: Setup Python
136+
uses: actions/setup-python@v4
137+
with:
138+
python-version: 3.8
139+
140+
- name: Install Python dependencies
141+
run: |
142+
pip install --upgrade pip
143+
pip install .
144+
pip install ".[test]"
145+
146+
# actions/download-artifact won't look at previous workflow runs but we need to in order to get changelog
147+
- name: Download artifacts
148+
uses: dawidd6/action-download-artifact@v2
149+
150+
- name: Draft release
151+
env:
152+
GITHUB_TOKEN: ${{ github.token }}
153+
run: |
154+
version=$(python scripts/update_version.py -g)
155+
title="modflowapi $version"
156+
notes=$(cat "changelog/CHANGELOG.md" | grep -v "### Version $version")
157+
gh release create "$version" \
158+
--target main \
159+
--title "$title" \
160+
--notes "$notes" \
161+
--draft \
162+
--latest
163+
164+
publish:
165+
name: Publish package
166+
# runs only after release is published (manually promoted from draft)
167+
if: github.event_name == 'release' && github.repository_owner == 'MODFLOW-USGS'
168+
runs-on: ubuntu-22.04
169+
permissions:
170+
contents: write
171+
pull-requests: write
172+
id-token: write
173+
environment: # requires a 'release' environment in repo settings
174+
name: release
175+
url: https://pypi.org/p/modflowapi
176+
steps:
177+
178+
- name: Checkout main branch
179+
uses: actions/checkout@v3
180+
with:
181+
ref: main
182+
183+
- name: Setup Python
184+
uses: actions/setup-python@v4
185+
with:
186+
python-version: 3.8
187+
188+
- name: Install Python dependencies
189+
run: |
190+
pip install --upgrade pip
191+
pip install build twine
192+
pip install .
193+
194+
- name: Build package
195+
run: python -m build
196+
197+
- name: Check package
198+
run: twine check --strict dist/*
199+
200+
- name: Upload package
201+
uses: actions/upload-artifact@v4
202+
with:
203+
name: dist
204+
path: dist
205+
206+
- name: Publish to PyPI
207+
uses: pypa/gh-action-pypi-publish@release/v1

CITATION.cff

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ message: If you use this software, please cite both the article from preferred-c
33
and the software itself.
44
type: software
55
title: MODFLOW API
6-
version: 0.1.0
6+
version: 0.2.0
77
date-released: '2023-04-19'
88
abstract: An extension to xmipy for the MODFLOW API.
99
repository-artifact: https://pypi.org/project/modflowapi

HISTORY.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Changelog
2+
### Version 0.2.0
3+
4+
#### Refactoring
5+
6+
* [refactor(rhs, hcof)](https://github.com/MODFLOW-USGS/modflowapi/commit/c0f681c5b7525388ead4df8c6363c1b4514d6de6): Updates to allow setting values when rhs and hcof have not yet had pointers set.. Committed by Joshua Larsen on 2023-04-28.
7+
* [refactor(Quickstart.ipynb)](https://github.com/MODFLOW-USGS/modflowapi/commit/3b6675aa687f5af01813abfdb143c7ddd4343646): Fix error in callback_function. Committed by Joshua Larsen on 2023-07-17.
8+
* [refactor(rhs, hcof)](https://github.com/MODFLOW-USGS/modflowapi/commit/ce4e50286d66da51c6b05f0de29c7c646344f6ce): Allow setting rhs and hcof when pointers have not been previously set. Committed by Joshua Larsen on 2023-07-17.
9+
* [refactor](https://github.com/MODFLOW-USGS/modflowapi/commit/e693282611d5863bafeece362230a4aadd02311f): Update libmf6 path handling (#27). Committed by w-bonelli on 2023-08-03.
10+
* [refactor(_ptr_to_recarray)](https://github.com/MODFLOW-USGS/modflowapi/commit/5a631592f2da57bf1564c263e9602c46e5a5a50c): Slice pointers prior to setting data to recarray. Committed by Joshua Larsen on 2023-08-08.
11+
* [refactor(_ptr_to_recarray)](https://github.com/MODFLOW-USGS/modflowapi/commit/959fe31abda263a52d01262af7dc4c2a878eadb5): Slice pointers prior to setting data to recarray. Committed by Joshua Larsen on 2023-08-08.
12+
* [refactor(extensions)](https://github.com/MODFLOW-USGS/modflowapi/commit/c97339d06e7386055e486f6354825ec15cea4638): Add support for IDM changes. Committed by Joshua Larsen on 2023-12-21.
13+
* [refactor(extensions)](https://github.com/MODFLOW-USGS/modflowapi/commit/de0aff9c21d5d925235f306fd2b3d148c3281efa): Add support for IDM changes. Committed by Joshua Larsen on 2023-12-21.
14+
15+
### Version 0.1.0
16+
17+
* Fix typo in README (https://github.com/MODFLOW-USGS/modflowapi/pull/4)
18+
* modflowapi interface (https://github.com/MODFLOW-USGS/modflowapi/pull/8)
19+
* update package: manual variable address assembly updated to use xmipy get_variable_addr()
20+
* update additional manual variable address assembly statements
21+
* Refactor code and added functionality:
22+
* add stress_period_start, stress_period_end Callbacks
23+
* fix ApiModel __repr__
24+
* added Exchanges, TDIS, ATS, and SLN support
25+
* added ScalarInput and ScalarPackage support
26+
* update autotests
27+
* added parallel testing support through pytest-xdist
28+
* updated markers and split the extensions tests from the mf6 examples tests
29+
* added a test for ATS
30+
* update setup.cfg
31+
* update ci.yml
32+
* update(ListInput): add auxvar to stress_period_data when auxiliary variables are used
33+
* Allow None to be passed to stress_period_data.values to disable stresses for a package
34+
* updates: ApiModel, ApiSimulation, run_simulation
35+
* added a `totim` property on `ApiSimulation` and `ApiModel`
36+
* added docstrings to ApiModel property methods
37+
* updated termination message in run_simulation
38+
* added a finalize callback to Callbacks and run_simulation
39+
* add support for AUXNAME_CST
40+
* add(Head Monitor Example): Add a head monitor example application
41+
* ApiModel: adjust X based on nodetouser
42+
* ApiPackage: enforce lower cased variable names in get_advanced_var
43+
* ArrayPointer: trap for arrays that are not adjusted by reduced node numbers (ex. idomain)
44+
* update setup.cfg
45+
* try reformatting the xmipy installation instructions
46+
* fix(get value): fixed error handling when modflowapi fails to get a pointer to a value from the API (https://github.com/MODFLOW-USGS/modflowapi/pull/9)
47+
Co-authored-by: scottrp <[email protected]>
48+
* update(rhs, hcof, AdvancedInput): bug fixes for setting variable values for advanced inputs
49+
* update rhs and hcof to copy values to pointer instead of overwriting the pointer
50+
* add a check for AdvancedInput variables that do not have pointer support in xmipy
51+
* update setting routine for AdvancedInput
52+
* refactor(EOL): change CRLF to LF line endings for source files (https://github.com/MODFLOW-USGS/modflowapi/pull/12)
53+
* Use pyproject.toml for project metadata, add citation info (https://github.com/MODFLOW-USGS/modflowapi/pull/11)
54+
* add(test_rhs_hcof_advanced): add additional test (https://github.com/MODFLOW-USGS/modflowapi/pull/13)
55+
* added test for getting and setting rhs, hcof, and advanced variable values
56+
* update project to use unix line separators
57+
* use np.testing.assert_allclose() instead of AssertionError
58+
* Add missing RIV support to modflowapi (https://github.com/MODFLOW-USGS/modflowapi/pull/16)
59+
* add(test_rhs_hcof_advanced): add additional test
60+
* added test for getting and setting rhs, hcof, and advanced variable values
61+
* update project to use unix line separators
62+
* use np.testing.assert_allclose() instead of AssertionError
63+
* Add missing riv package to modflowapi
64+
65+
### Version 0.0.1
66+
67+
Initial release.

autotest/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# init file for pytest
1+
# init file for pytest

autotest/conftest.py

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def get_mf6_examples_path() -> Path:
3131
finally:
3232
__mf6_examples_lock.release()
3333

34+
3435
def is_nested(namfile) -> bool:
3536
p = Path(namfile)
3637
if not p.is_file() or not p.name.endswith(".nam"):

0 commit comments

Comments
 (0)