Skip to content

Commit 1510020

Browse files
authored
Merge pull request #331 from EC-USGS/v2.0.2
Release 2.0.2
2 parents d2a77da + f2e829f commit 1510020

33 files changed

+225
-1042
lines changed

.github/workflows/ci.yaml

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@ on:
1313
inputs:
1414
debug_enabled:
1515
type: boolean
16-
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
16+
description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
1717
required: false
1818
default: false
1919

2020
jobs:
21-
22-
pyws_setup:
21+
pws_install:
2322
name: standard installation
2423
runs-on: ubuntu-latest
2524
strategy:
@@ -39,13 +38,48 @@ jobs:
3938
- name: Upgrade pip and install build and twine
4039
run: |
4140
python -m pip install --upgrade pip
42-
pip install wheel build 'twine<5.0.0' 'importlib_metadata<=7.0.1' 'setuptools<=72.2.0' 'numpy<2.0'
41+
pip install wheel build twine importlib_metadata setuptools numpy
4342
44-
- name: Base installation
43+
- name: Standard installation
4544
run: |
4645
pip --verbose install .
4746
48-
- name: Print pyhmn version
47+
- name: Print pws version
48+
run: |
49+
python -c "import pywatershed; print(pywatershed.__version__)"
50+
51+
- name: Build pywatershed, check dist outputs
52+
run: |
53+
python -m build
54+
twine check --strict dist/*
55+
56+
pws_editable_install:
57+
name: editable installation
58+
runs-on: macos-latest
59+
strategy:
60+
fail-fast: false
61+
defaults:
62+
run:
63+
shell: bash
64+
steps:
65+
- name: Checkout repo
66+
uses: actions/checkout@v4
67+
68+
- name: Setup Python
69+
uses: actions/setup-python@v5
70+
with:
71+
python-version: "3.11"
72+
73+
- name: Upgrade pip and install build and twine
74+
run: |
75+
python -m pip install --upgrade pip
76+
pip install wheel build twine importlib_metadata setuptools numpy
77+
78+
- name: Editable installation
79+
run: |
80+
pip --verbose install -e .
81+
82+
- name: Print pws version
4983
run: |
5084
python -c "import pywatershed; print(pywatershed.__version__)"
5185
@@ -97,11 +131,10 @@ jobs:
97131
strategy:
98132
fail-fast: false
99133
matrix:
100-
os: [ "ubuntu-latest", "macos-latest", "windows-latest" ]
134+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
101135
python-version: ["3.10", "3.11"]
102136

103137
steps:
104-
105138
- name: Free Disk Space (Ubuntu)
106139
if: runner.os == 'Linux'
107140
uses: jlumbroso/free-disk-space@main
@@ -151,7 +184,7 @@ jobs:
151184
- name: Install Dependencies via Micromamba
152185
uses: mamba-org/[email protected]
153186
with:
154-
micromamba-version: '1.5.10-0'
187+
micromamba-version: "1.5.10-0"
155188
log-level: debug
156189
environment-file: environment.yml
157190
cache-environment: true
@@ -318,7 +351,6 @@ jobs:
318351
--cov-report=xml
319352
--junitxml=pytest_drb_2yr_no_dprst.xml
320353

321-
322354
- name: ucb_2yr_nhm - generate and manage test data
323355
working-directory: autotest
324356
run: |
@@ -358,7 +390,7 @@ jobs:
358390
- name: Upload code coverage to Codecov
359391
uses: codecov/codecov-action@v3
360392
with:
361-
file: ./autotest/coverage.xml # should be just the ucb result
393+
file: ./autotest/coverage.xml # should be just the ucb result
362394
# flags: unittests
363395
env_vars: RUNNER_OS,PYTHON_VERSION
364396
# name: codecov-umbrella

.github/workflows/ci_examples.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ on:
1111
- "!v[0-9]+.[0-9]+.[0-9]+*"
1212

1313
jobs:
14-
1514
test:
1615
name: ${{ matrix.os}} py${{ matrix.python-version }}
1716

@@ -24,8 +23,8 @@ jobs:
2423
strategy:
2524
fail-fast: false
2625
matrix:
27-
os: [ "ubuntu-latest" ]
28-
python-version: [ "3.10"]
26+
os: ["ubuntu-latest"]
27+
python-version: ["3.10"]
2928

3029
steps:
3130
- name: Checkout repo
@@ -37,15 +36,10 @@ jobs:
3736
compiler: gcc
3837
version: 11
3938

40-
- name: Set environment variables
41-
run: |
42-
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
43-
echo "SETUPTOOLS_ENABLE_FEATURES=legacy-editable" >> $GITHUB_ENV
44-
4539
- name: Setup micromamba
4640
uses: mamba-org/[email protected]
4741
with:
48-
micromamba-version: '1.5.10-0'
42+
micromamba-version: "1.5.10-0"
4943
environment-file: environment_w_jupyter.yml
5044
cache-environment: true
5145
cache-downloads: true

README.md

Lines changed: 14 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@
1515

1616
[![DOI:10.5066/P13EWPEV](https://img.shields.io/badge/DOI-10.5066/P13EWPEV-b4a9fe.svg)](https://doi.org/10.5066/P13EWPEV)
1717

18-
[![WholeTale](https://raw.githubusercontent.com/whole-tale/wt-design-docs/master/badges/wholetale-explore.svg)](https://dashboard.wholetale.org/run/64ae29e8a887f48b9f173678?tab=metadata)
19-
20-
2118
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2219
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
23-
**Table of Contents**
2420

2521
- [About](#about)
2622
- [Installation](#installation)
@@ -51,34 +47,34 @@ of well-established hydrologic process modeling.
5147

5248
For more information on the goals and status of pywatershed, please see the [pywatershed docs](https://pywatershed.readthedocs.io/).
5349

54-
5550
## Installation
5651

5752
`pywatershed` uses Python 3.10 or 3.11.
5853

5954
The `pywatershed` package is [available on
6055
PyPI](https://pypi.org/project/pywatershed/) but installation of all
6156
dependencies sets (lint, test, optional, doc, and all) may not be reliable on
62-
all platforms.
57+
all platforms.
6358

6459
The `pywatershed` package is [available on
6560
conda-forge](https://anaconda.org/conda-forge/pywatershed). The installation
6661
is the quickest way to get up and running by provides only the minimal set of
6762
dependencies (not including Jupyter nor all packages needed for running the
68-
example notebooks, also not suitable for development purposes).
63+
example notebooks, also not suitable for development purposes).
6964

7065
We recommend the following installation procedures to get fully-functional
7166
environments for running `pywatershed` and its example notebooks. We strongly
7267
recommend using [Mamba](https://mamba.readthedocs.io/en/latest/)to first
7368
instal dependencies from the `environment_y_jupyter.yml` file in the
7469
repository before installing `pywatershed` itself. Mamba will be much faster
75-
than Ananconda (but the conda command could also be used).
70+
than Ananconda (but the conda command could also be used).
7671

77-
If you wish to use the stable release, you will use `main` in place of
72+
If you wish to use the stable release, you will use `main` in place of
7873
`<branch>` in the following commands. If you want to follow development, you'll
7974
use `develop` instead.
8075

8176
Without using `git` (directly), you may:
77+
8278
```
8379
curl -L -O https://raw.githubusercontent.com/EC-USGS/pywatershed/<branch>/environment_w_jupyter.yml
8480
mamba env create -f environment_w_jupyter.yml
@@ -97,53 +93,35 @@ pip install -e .
9793
```
9894

9995
(If you want to name the environment other than the default `pws`, use the
100-
command
96+
command
10197
`mamba env update --name your_env_name --file environment_w_jupyter.yml --prune`
10298
you will also need to activate this environment by name.)
10399

104-
105-
We install the `environment_w_jupyter.yml` to provide all known dependencies
106-
including those for running the example notebooks. (The `environment.yml`
107-
does not contain Jupyter or JupyterLab because this interferes with installation
108-
on WholeTale, see Getting Started section below.)
109-
100+
We install the `environment_w_jupyter.yml` to provide all known dependencies
101+
including those for running the example notebooks.
110102

111103
## Getting started / Example notebooks
112104

113105
Please note that you can browse the API reference, developer info, and index
114-
in the [pywatershed docs]((https://pywatershed.readthedocs.io/)). But
115-
*the best way to get started with pywatershed is to dive into the example
116-
notebooks*.
106+
in the [pywatershed docs](<(https://pywatershed.readthedocs.io/)>). But
107+
_the best way to get started with pywatershed is to dive into the example
108+
notebooks_.
117109

118110
For introductory example notebooks, look in the
119111
[`examples/`](https://github.com/EC-USGS/pywatershed/tree/main/examples>)
120112
directory in the repository. Numbered starting at 00, these are meant to be
121113
completed in order. Numbered starting at 00, these are meant to be completed
122-
in order. Notebook outputs are not saved in Github. But you can run these
123-
notebooks locally or using WholeTale (an NSF funded project supporting logins
124-
from many institutions, free but sign-up or log-in required)
125-
where the pywatershed environment is all ready to go:
126-
127-
[![WholeTale](https://raw.githubusercontent.com/whole-tale/wt-design-docs/master/badges/wholetale-explore.svg)](https://dashboard.wholetale.org)
128-
129-
* [Run latest release in WholeTale](https://dashboard.wholetale.org/run/64ae29e8a887f48b9f173678?tab=metadata)
130-
* [Run the develop branch in WholeTale](https://dashboard.wholetale.org/run/64ae25c3a887f48b9f1735c8?tab=metadata)
131-
132-
WholeTale will give you a JupyterLab running in the root of this
133-
repository. You can navigate to `examples/` and then open and run the notebooks
134-
of your choice. The develop container may require the user to update the
135-
repository (`git pull origin`) to stay current with development.
114+
in order. Notebook outputs are not saved in Github.
136115

137116
Non-numbered notebooks in `examples/` cover additional topics. These
138117
notebooks are not yet covered by testing and you may encounter some
139118
issues. In `examples/developer/` there are notebooks of interest to
140119
developers who may want to learn about running the software tests.
141120

142-
143121
## Community engagement
144122

145123
We value your feedback! Please use [discussions](https://github.com/EC-USGS/pywatershed/discussions)
146-
or [issues](https://github.com/EC-USGS/pywatershed/issues) on Github.
124+
or [issues](https://github.com/EC-USGS/pywatershed/issues) on Github.
147125
For more in-depth contributions, please start by reading over
148126
the pywatershed
149127
[DEVELOPER.md](https://github.com/EC-USGS/pywatershed/blob/develop/DEVELOPER.md) and
@@ -164,4 +142,4 @@ software as needed pursuant to further analysis and review. No warranty, express
164142
is made by the USGS or the U.S. Government as to the functionality of the software and related
165143
material nor shall the fact of release constitute any such warranty. Furthermore, the software
166144
is released on condition that neither the USGS nor the U.S. Government shall be held liable
167-
for any damages resulting from its authorized or unauthorized use.
145+
for any damages resulting from its authorized or unauthorized use.

autotest/ci_local.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if [ ! -z "${h}" ]; then
8989

9090
exit 0
9191
fi
92-
92+
9393
echo ""
9494
echo ""
9595

@@ -119,8 +119,7 @@ if [ -z "${i}" ]; then
119119

120120
## name: Upgrade pip and install build and twine
121121
python -m pip install --upgrade pip || exit 1
122-
pip install wheel build 'twine<5.0.0' 'importlib_metadata<=7.0.1' || exit 1
123-
122+
pip install wheel build twine importlib_metadata || exit 1
124123
## name: Base installation
125124
pip --verbose install . || exit 1
126125

@@ -194,8 +193,8 @@ if [ -z "${m}" ]; then
194193
# mamba create -y --name $env_name || exit 1
195194
# mamba env update --name $env_name --file $env_file --prune || exit 1
196195

197-
# conda activate $env_name
198-
source /Users/jmccreight/mambaforge/bin/activate $env_name
196+
conda_dir=`dirname $CONDA_EXE`
197+
source $conda_dir/activate $env_name || exit 1
199198
# only necessary the first time
200199
# meson setup --prefix=$(pwd) --libdir=bin builddir
201200
meson install -C builddir
@@ -437,17 +436,18 @@ if [ -z "${t}" ]; then
437436
--control_pattern=nhm.control \
438437
--durations=0 || exit 1
439438
fi
440-
439+
441440
fi
442441

443442
if [ -z "${i}" ]; then
443+
cd $start_dir || exit 3
444444
# If install was done, put the install back to its original, editable state.
445445
# Do it here so the tests use the test install if it is done.
446446
pip uninstall -y pywatershed || exit 1
447447
cd .. || exit 1
448-
pip install -e . || exit 1
448+
pip install -e . || exit 2
449449

450-
cd $start_dir || exit 1
450+
cd $start_dir || exit 3
451451
fi
452452

453453
exit 0

autotest/generate_test_data.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ def main():
205205
"convert_prms_output_to_nc.py",
206206
]
207207

208+
# do NOT run in parallel
209+
conv_final_arg_list = arg_list + [
210+
"-vv",
211+
"-n=0",
212+
"convert_final_prms_output_to_nc.py",
213+
]
214+
208215
retcode_run = pytest.main(run_arg_list)
209216
if retcode_run != pytest.ExitCode.OK:
210217
print("Running PRMS domains failed.")
@@ -216,6 +223,12 @@ def main():
216223
print("\nConverting PRMS output to NetCDF failed.")
217224
sys.exit(retcode_run.value)
218225

226+
print("\nConverting final PRMS output to NetCDF ...")
227+
retcode_conv = pytest.main(conv_final_arg_list)
228+
if retcode_conv != pytest.ExitCode.OK:
229+
print("\nConverting final PRMS output to NetCDF failed.")
230+
sys.exit(retcode_run.value)
231+
219232
for ss in simulations:
220233
ss_pl = pl.Path(ss)
221234
domain_tag = ss_pl.parent.name

autotest/test_netcdf_read.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ def test_netcdf(simulation):
1212

1313
for idx in range(ntimes):
1414
arr = nc_data.advance(variable)
15-
assert (
16-
arr.shape == shape
17-
), f"shape is {arr.shape} but should be {shape}"
15+
assert arr.shape == shape, (
16+
f"shape is {arr.shape} but should be {shape}"
17+
)
1818

1919
shape = (ntimes, nhru)
2020
arr = nc_data.get_data(variable)

autotest/test_preprocess_csv.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def compare_netcdf(csv, nc_name):
2626
for idx, hru in enumerate(hrus):
2727
key = f"{variable}_{hru}"
2828
csv_data[:, idx] = np_data[key][:]
29-
assert np.allclose(
30-
nc_data, csv_data
31-
), f"comparision for {variable} is not close"
29+
assert np.allclose(nc_data, csv_data), (
30+
f"comparision for {variable} is not close"
31+
)
3232

3333
# close the netcdf file and return
3434
ds.close()

0 commit comments

Comments
 (0)