Skip to content

Commit 8503ca7

Browse files
authored
Merge pull request #224 from EC-USGS/v0.2.1
Release 0.2.1
2 parents 8188a59 + 85d9691 commit 8503ca7

13 files changed

+145
-78
lines changed

.github/PULL_REQUEST_TEMPLATE.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<!-- Feel free to remove check-list items aren't relevant to your change -->
22

33
- [ ] Closes #xxxx
4-
- [ ] Tests and/or performance benchmarks added
4+
- [ ] Tests added
5+
- [ ] Performance benchmarks added
6+
- [ ] Performance regression benchmarks run
57
- [ ] User visible changes (including notable bug fixes) are documented in `whats-new.rst`
68
- [ ] New functions/methods are listed in `api.rst` or it's sub rsts?

.github/RELEASE.md

+13-11
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,21 @@ To release a new version:
4747
remote: `git push -u upstream vx.y.z`. This starts a job to:
4848

4949
- Check out the release branch Update version number in `version.txt` and
50-
- `pywatershed/version.py` to match the version in the branch name Build and
51-
- check the Python package Generate a changelog since the last release
52-
- Prepend the changelog to the cumulative `HISTORY.md` Upload the package
53-
- and changelog as artifacts Draft a PR against `main` with the updated
54-
- version files and cumulative changelog. The cumulative `HISTORY.md` is
55-
- version-controlled, release changelogs are not.
50+
`pywatershed/version.py` to match the version in the branch name
51+
- Build and check the Python package Generate a changelog since the last
52+
release
53+
- Prepend the changelog to the cumulative `HISTORY.md`. The cumulative
54+
`HISTORY.md` is version-controlled, release changelogs are not.
55+
- Upload the package and changelog as artifacts Draft a PR against `main`
56+
with the updated version files and cumulative changelog.
5657

5758
1. On all platforms, pull the release from upstream and perform ASV performance
58-
benchmarks against previous release , e.g., ``` asv continuous --verbose
59-
--show-stderr --factor 1.3 previous_release this_release ``` Collect
60-
performance reports from various machines into a single report and use `asv
61-
publish` to generate the static webpages to be included with the release as
62-
artifacts in that step below.
59+
benchmarks against previous release , e.g., ```asv run --verbose
60+
--show-stderr HASHFILE:pws_refs_for_asv.txt``` after editing the file to
61+
contain the previous and current release. Collect performance results from
62+
various machines into a single report and use `asv publish` to generate
63+
the static webpages to be included with the release as artifacts in that
64+
step below.
6365

6466
1. Inspect the package and changelog. If they look good, merge the PR to `main`.
6567

.github/workflows/release.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,14 @@ jobs:
193193
run: |
194194
version=$(cat version.txt | xargs)
195195
title="pywatershed $version"
196-
notes=$(cat "changelog/CHANGELOG_$version.md" | grep -v "### Version $version")
196+
197+
# don't fail if the changelog is empty
198+
if [[ -s "changelog/CHANGELOG_$version.md" ]]; then
199+
notes=$(cat "changelog/CHANGELOG_$version.md" | grep -v "### Version $version")
200+
else
201+
notes="No changes found, are recent commits conventional?"
202+
fi
203+
197204
gh release create "$version" \
198205
--target main \
199206
--title "$title" \

README.md

+67-42
Original file line numberDiff line numberDiff line change
@@ -38,56 +38,80 @@ The following motivations are taken from our [AGU poster from December
3838
which provides additional details on motivations, project status, and current
3939
directions of this project as of approximately January 2023.
4040

41-
Goals of the USGS Enterprise Capacity (EC) project include: * A sustainable
42-
integrated, hydrologic modeling framework for the U.S. Geological Survey (USGS)
43-
* Interoperable modeling across the USGS, partner agencies, and academia
44-
45-
Goals for EC Watershed Modeling: * Couple the Precipitation-Runoff Modeling
46-
System (PRMS, e.g. Regan et al, 2018)  with MODFLOW 6 (MF6, e.g. Langevin et al,
47-
2017) in a sustainable way * Redesign PRMS to be more modern and flexible *
48-
Prioritize process representations in the current National Hydrological Model
49-
(NHM) based on PRMS 5.2.1
50-
51-
Prototype an EC watershed model: "pywatershed" * Redesign PRMS quickly in python
52-
* Couple to MF6 via BMI/XMI interface (Hughes et al, 2021; Hutton et al, 2020) *
53-
Establish a prototyping ground for EC codes that couples to the compiled
54-
framework: low cost proof of concepts (at the price of potentially less
55-
computational performance) * Enable process representation hypothesis testing *
56-
Use cutting-edge techniques and technologies to improve models * Machine
57-
learning, automatic differentiation * Address challenges of modeling across
58-
space and time scales * Transition prototype watershed model to compiled EC code
41+
Goals of the USGS Enterprise Capacity (EC) project include:
5942

60-
## Installation
43+
* A sustainable integrated, hydrologic modeling framework for the U.S.
44+
Geological Survey (USGS)
45+
* Interoperable modeling across the USGS, partner agencies, and academia
46+
47+
Goals for EC Watershed Modeling:
6148

62-
To install the software you will need Python 3.9 or 3.10.
49+
* Couple the Precipitation-Runoff Modeling System (PRMS, e.g. Regan et al,
50+
2018)  with MODFLOW 6 (MF6, e.g. Langevin et al, 2017) in a sustainable
51+
way
52+
* Redesign PRMS to be more modern and flexible
53+
* Prioritize process representations in the current National Hydrological
54+
Model (NHM) based on PRMS 5.2.1
6355

64-
We currently recommend dependencies be installed with
65-
[Mamba](https://mamba.readthedocs.io/en/latest/) which will be much faster than
66-
Ananconda (but the conda command can also be used). An environment containing
67-
all core and optional dependencies can be created from the project root with:
56+
Prototype an EC watershed model: "pywatershed"
6857

69-
```mamba env create -f environment_w_jupyter.yml```
58+
* Redesign PRMS quickly in python
59+
* Couple to MF6 via BMI/XMI interface (Hughes et al, 2021; Hutton et al, 2020)
60+
* Establish a prototyping ground for EC codes that couples to the compiled
61+
framework: low cost proof of concepts (at the price of potentially less
62+
computational performance) * Enable process representation hypothesis testing
63+
* Use cutting-edge techniques and technologies to improve models
64+
* Machine learning, automatic differentiation
65+
* Address challenges of modeling across space and time scales
66+
* Transition prototype watershed model to compiled EC code
7067

71-
(The environment `environment.yml` does not contain jupyter or jupyterlab
72-
in order to not interfere with installation in WholeTale, see Example
73-
Notebooks seection below.)
68+
69+
## Installation
70+
71+
`pywatershed` uses Python 3.9 or 3.10.
7472

7573
The `pywatershed` package is [available on
76-
PyPI](https://pypi.org/project/pywatershed/). At the moment, the installation
77-
may not be reliable on all platforms and we are working to fix this.
74+
PyPI](https://pypi.org/project/pywatershed/) but installation of dependencies
75+
may not be reliable on all platforms.
7876

79-
Using PyPI (with the above caveat), `pywatershed` can be installed with:
77+
We recommend dependencies be first installed with
78+
[Mamba](https://mamba.readthedocs.io/en/latest/). This will be much faster than
79+
Ananconda (but the conda command could also be used). We hope to provide
80+
`pywatershed` installation with all its dependencies on conda-forge in the
81+
near future.
8082

81-
``` pip install pywatershed ```
83+
If you wish to use the stable release, you will use `main` in place of
84+
`<branch>` in the following commands. If you want to follow developemnt, you'll
85+
use `develop` instead.
8286

83-
A number of extra dependencies are needed to run the example notebooks. These
84-
can be installed with pip with
87+
Without using `git` (directly), you may:
88+
```
89+
curl -L -O https://raw.githubusercontent.com/EC-USGS/pywatershed/<branch>/environment_w_jupyter.yml
90+
mamba env create -f environment_w_jupyter.yml
91+
conda activate pws
92+
pip install git+https://github.com/EC-USGS/pywatershed.git@<branch>
93+
```
8594

86-
``` pip install "pywatershed[optional]" ```
95+
Or to use `git` and to be able to develop:
8796

88-
These installation steps are suitable for `pywatershed` end users. See the
89-
[developer documentation](./DEVELOPER.md) for detailed instructions on
90-
configuring a development environment.
97+
```
98+
git clone https://github.com/EC-USGS/pywatershed.git
99+
cd pywatershed
100+
mamba env create -f environment_w_jupyter.yml
101+
activate pws
102+
pip install -e .
103+
```
104+
105+
(If you want to name the environment other than the default `pws`, use the
106+
command
107+
`mamba env update --name your_env_name --file environment_w_jupyter.yml --prune`
108+
you will also need to activate this environment by name.)
109+
110+
111+
We install the `environment_w_jupyter.yml` to provide all known dependencies
112+
including those for running the eample notebooks. (The `environment.yml`
113+
does not contain jupyter or jupyterlab because this interferes with installation
114+
on WholeTale, see Example Notebooks seection below.)
91115

92116
## Contributing
93117

@@ -116,10 +140,11 @@ to register.
116140
There are containers for both the `main` and `develop` branches.
117141

118142
[![WholeTale](https://raw.githubusercontent.com/whole-tale/wt-design-docs/master/badges/wholetale-explore.svg)](https://dashboard.wholetale.org)
119-
* [WholeTale container for latest release (main
120-
branch)](https://dashboard.wholetale.org/run/64ae29e8a887f48b9f173678?tab=metadata)
121-
* [WholeTale container for develop
122-
branch](https://dashboard.wholetale.org/run/64ae25c3a887f48b9f1735c8?tab=metadata)
143+
144+
* [WholeTale container for latest release (main
145+
branch)](https://dashboard.wholetale.org/run/64ae29e8a887f48b9f173678?tab=metadata)
146+
* [WholeTale container for develop
147+
branch](https://dashboard.wholetale.org/run/64ae25c3a887f48b9f1735c8?tab=metadata)
123148

124149
WholeTale will give you a jupyter-lab running in the root of this
125150
repository. You can navigate to `examples/` and then open and run the notebooks

asv_benchmarks/benchmarks/prms.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -85,17 +85,17 @@ def setup(self, *args):
8585
else:
8686
self.params = pws.PrmsParameters.load(self.parameter_file)
8787

88-
# backwards compatability
88+
# backwards compatability pre 0.2.0
8989
try:
90+
self.ge_v0_2_0 = False
9091
self.control = pws.Control.load(
9192
self.control_file, params=self.params
9293
)
93-
self.ge_v0_2_0 = False
9494
except:
95-
self.control = pws.Control.load(self.control_file)
9695
self.ge_v0_2_0 = True
9796

98-
self.control.edit_n_time_steps(n_time_steps)
97+
if hasattr(self, "control"):
98+
del self.control
9999

100100
# setup input_dir with symlinked prms inputs and outputs
101101
self.domain_dir = pl.Path(f"PRMSModels_{self.domain}")
@@ -119,17 +119,28 @@ def model_setup_run(
119119
processes: tuple = None,
120120
write_output: Union[bool, Literal["separate", "together"]] = None,
121121
):
122+
# seem to need to load control inside the model setup run bc
123+
# results are strange/inconsistent
124+
122125
if self.ge_v0_2_0:
126+
self.control = pws.Control.load(self.control_file)
123127
self.control.options["input_dir"] = self.tag_input_dir
124128
self.control.options["budget_type"] = "warn"
125129
self.control.options["calc_method"] = "numba"
130+
self.control.edit_n_time_steps(n_time_steps)
126131

127132
model = pws.Model(
128133
self.processes,
129134
control=self.control,
130135
parameters=self.params,
131136
)
137+
132138
else:
139+
self.control = pws.Control.load(
140+
self.control_file, params=self.params
141+
)
142+
self.control.edit_n_time_steps(n_time_steps)
143+
133144
model = pws.Model(
134145
*self.processes,
135146
control=self.control,
@@ -143,6 +154,8 @@ def model_setup_run(
143154
self.tag_dir, separate_files=(write_output == "separate")
144155
)
145156
model.run(finalize=True)
157+
del model
158+
del self.control
146159

147160
@parameterized(
148161
["domain", "processes", "output"],

asv_benchmarks/pws_refs_for_asv.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
0.1.1
2+
0.2.0
3+

doc/whats-new.rst

+14-1
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,22 @@ What's New
1212
np.random.seed(123456)
1313
1414
15+
.. _whats-new.0.2.1:
16+
17+
v0.2.1 (19 July 2023)
18+
---------------------
19+
20+
Bug fixes
21+
~~~~~~~~~
22+
- Package data was not properly installed.
23+
(:pull:`219`) By `James McCreight <https://github.com/jmccreight>`_.
24+
- Small addition to notebook 02
25+
(:pull:`219`) By `James McCreight <https://github.com/jmccreight>`_.
26+
27+
1528
.. _whats-new.0.2.0:
1629

17-
v0.2.0 (12 July 2023)
30+
v0.2.0 (18 July 2023)
1831
---------------------
1932

2033
New features

environment.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: pywatershed
1+
name: pws
22
channels:
33
- conda-forge
44
- nodefaults
@@ -11,12 +11,11 @@ dependencies:
1111
- filelock
1212
- geopandas
1313
- geoviews
14+
- git
1415
- holoviews
1516
- hvplot
16-
- git
1717
- ipython
1818
- ipywidgets
19-
- jupyter_contrib_nbextensions
2019
- nb_conda_kernels
2120
- nbconvert
2221
- netCDF4
@@ -43,11 +42,12 @@ dependencies:
4342
- tqdm
4443
- xarray>=2023.05.0
4544
- pip:
46-
- click != 8.1.0
45+
- asv
4746
- black
47+
- click != 8.1.0
4848
- isort
4949
- flake8
50-
- jupyter_black
51-
- pylint
5250
- git+https://github.com/modflowpy/flopy.git
51+
- jupyter_black
5352
- modflow-devtools
53+
- pylint

environment_w_jupyter.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: pywatershed
1+
name: pws
22
channels:
33
- conda-forge
44
- nodefaults
@@ -11,13 +11,12 @@ dependencies:
1111
- filelock
1212
- geopandas
1313
- geoviews
14+
- git
1415
- holoviews
1516
- hvplot
16-
- git
1717
- ipython
1818
- ipywidgets
1919
- jupyter
20-
- jupyter_contrib_nbextensions
2120
- jupyterlab
2221
- nb_conda_kernels
2322
- nbconvert
@@ -45,11 +44,12 @@ dependencies:
4544
- tqdm
4645
- xarray>=2023.05.0
4746
- pip:
48-
- click != 8.1.0
47+
- asv
4948
- black
49+
- click != 8.1.0
5050
- isort
5151
- flake8
52-
- jupyter_black
53-
- pylint
5452
- git+https://github.com/modflowpy/flopy.git
53+
- jupyter_black
5554
- modflow-devtools
55+
- pylint

examples/02_prms_legacy_models.ipynb

+4-2
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,10 @@
410410
" \"input_dir\": run_dir,\n",
411411
" \"budget_type\": \"warn\",\n",
412412
" \"calc_method\": \"numba\",\n",
413-
" # \"netcdf_output_dir\": nb_output_dir / \"nhm\",\n",
414-
"}"
413+
" \"netcdf_output_dir\": nb_output_dir / \"nhm_submodel\",\n",
414+
"}\n",
415+
"\n",
416+
"control.options[\"netcdf_output_var_names\"] = pws.PRMSChannel.get_variables()"
415417
]
416418
},
417419
{

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ include = ["pywatershed", "pywatershed.*"]
110110

111111
[tool.setuptools.package-data]
112112
"pywatershed.static.metadata" = ["*.yaml"]
113-
"pywatershed.data" = ["*.nc"]
113+
"pywatershed.data.drb_2yr" = ["*"]
114114

115115
[tool.black]
116116
line-length = 79

pywatershed/version.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# pywatershed version file automatically created using update_version.py on July 18, 2023 16:50:45
1+
# pywatershed version file automatically created using update_version.py on July 21, 2023 02:12:07
22

3-
__version__ = "0.2.0"
3+
__version__ = "0.2.1"
44
__pakname__ = "pywatershed"
55

66
author_dict = {

version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.2.0
1+
0.2.1

0 commit comments

Comments
 (0)