Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat flow dag #233

Merged
merged 128 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
bf5c1dc
FlowGraph and PRMSChannelFlowGraph skeleton with tests passing
jmccreight Jul 20, 2023
2e30acd
refactor of PRMS channel calculation
jmccreight Aug 4, 2023
5a44dc6
prms channel flow graph wip passing tests
jmccreight Aug 7, 2023
9f4460b
flowgraph partially working
jmccreight Aug 11, 2023
fde0b49
PRMS channel flow graph working completely
jmccreight Aug 11, 2023
eec963a
flowgraph cleanup
jmccreight Aug 11, 2023
95d4c2c
merge upstream/develop
jmccreight Aug 11, 2023
553ce8a
pin modflow-devtools < 1.0.0
jmccreight Aug 12, 2023
f6093d0
lint
jmccreight Aug 12, 2023
a3aa229
tolerance change
jmccreight Aug 13, 2023
0c7c4b0
prms channel & flow graph teset tolerances both 8e-6
jmccreight Aug 14, 2023
95dfd88
polish on FlowGraph and FlowNode
jmccreight Aug 15, 2023
6c4c6c7
refactor flow_graph to have _init_graph() and finalize_graph() method…
jmccreight Aug 16, 2023
0c07f14
more work on flowgraph
jmccreight Aug 17, 2023
52eff68
more work on flowgraph, move lateral inflows to init pass of referenc…
jmccreight Aug 17, 2023
c8e042a
more work on flowgraph, move lateral inflows to init pass of referenc…
jmccreight Aug 17, 2023
8547b7c
flowgraph revival
jmccreight Mar 6, 2024
a57a499
merge upstream/develop into feat_flow_dag
jmccreight Mar 6, 2024
67d4abd
changes for simplified adapter
jmccreight Mar 6, 2024
3c58d46
PrmsFlowNode and PassThroughNode tests passing
jmccreight Mar 7, 2024
7b4dbf7
move answer advance into test and not in comparison
jmccreight Mar 7, 2024
dfbed8b
lint
jmccreight Mar 7, 2024
4077b53
include the passthrough node; lint
jmccreight Mar 7, 2024
148c216
merge upstream/develop
jmccreight Mar 7, 2024
152061e
merge upstream/develop
jmccreight Mar 7, 2024
ea965b8
tweaks
jmccreight Mar 7, 2024
baae2f3
fix to tests; only test pass_through_flow_node on drb
jmccreight Mar 8, 2024
a799791
lint
jmccreight Mar 8, 2024
3f02d38
only test passthrough flow graph on drb_2yr:nhm
jmccreight Mar 9, 2024
a8efc0f
only test flow graph on drb_2yr:nhm
jmccreight Mar 9, 2024
041cf6a
prms_channel_flow_graph working and tested w/ budget, but still WIP
jmccreight Mar 13, 2024
58908b5
prms_channel_flow_graph and flow_graph moved to all flows and not flo…
jmccreight Mar 13, 2024
f0168e5
prms_channel_flow_graph now has numba nodes but there is no performan…
jmccreight Mar 14, 2024
d24095e
fix tests and get node_upstream_inflow tested
jmccreight Mar 14, 2024
a92bae5
fix up pass_through test, passing with budget
jmccreight Mar 14, 2024
4ee28ad
Subclass FlowGraph from Process, WIP
jmccreight Mar 14, 2024
10f0c85
Subclass FlowGraph from ConservativeProcess
jmccreight Mar 14, 2024
9c58d54
isort
jmccreight Mar 15, 2024
e434346
Update starfit with updated code from Noah Knowles
jmccreight Mar 18, 2024
d08b3e0
little cleanup in test_pass_through_flow_graph
jmccreight Mar 18, 2024
0fccce1
expressed starfit as a FlowNode and FlowNodeMaker and tested individu…
jmccreight Mar 19, 2024
9954ee6
ObsInNode working as a pass through
jmccreight Mar 19, 2024
bec993a
update starfit a bit
jmccreight Mar 19, 2024
022dd11
little clean up, syntax
jmccreight Mar 19, 2024
425e760
clean up subtimestepping in StarfitFlowNode
jmccreight Mar 19, 2024
6456a7d
ObsInNode working with data; added sink_source and get matching resul…
jmccreight Mar 20, 2024
1f6251c
lint
jmccreight Mar 20, 2024
28b3936
remove pyprms bc of pandas conflicts, add obsin config for drb_2yr
jmccreight Mar 20, 2024
c7be855
2 poi obsout_segment passes tests including mass balance; added sink_…
jmccreight Mar 21, 2024
2a87950
dubious way to turn off PyPRMS import, pending pandas 2.0 upgrade
jmccreight Mar 21, 2024
ff741ed
resolved some sink_source test issues
jmccreight Mar 22, 2024
fbf32c1
merge upstream/develop
jmccreight Apr 25, 2024
851c792
some minor change to go back and check issues with previous merge
jmccreight Apr 26, 2024
393da4b
minor fixes post merge of upstream/develop
jmccreight Apr 27, 2024
04deee6
just mark tests "domainless" and use "not domainless" to not need to …
jmccreight Apr 27, 2024
94a9c15
odds and ends (typo and lint)
jmccreight Apr 27, 2024
66c18ce
actually lint
jmccreight Apr 27, 2024
1c5be02
more testing fallout details from merge
jmccreight Apr 27, 2024
8dded0f
more testing details
jmccreight Apr 27, 2024
c48ceac
remove dependency on pyPRMS (pandas verson conflict) but stealing cod…
jmccreight Apr 29, 2024
52376e4
lint
jmccreight Apr 29, 2024
c40ac4d
lint 4 real
jmccreight Apr 29, 2024
3bd255a
refactor FlowGraph to use discretization and parameters
jmccreight Apr 29, 2024
e449352
missed a patch in the commit
jmccreight Apr 29, 2024
638189a
missed a another patch in the commit
jmccreight Apr 29, 2024
9e0069c
HruSegmentFlowExchange tested in memory
jmccreight Apr 30, 2024
560e798
lint
jmccreight Apr 30, 2024
431b043
fix test_obsin_flow_node
jmccreight Apr 30, 2024
8025e35
inflow_exchange_factory
jmccreight Apr 30, 2024
af00f9f
refactor test_passs_through_flow_graph
jmccreight May 1, 2024
31af687
inflow_exchange_factory used for pass through node
jmccreight May 1, 2024
3714b21
fix mass balance issue in starfit prior to more refactoring
jmccreight May 3, 2024
350e691
starfit can also take and return cfs, though the tests do not match e…
jmccreight May 7, 2024
407168c
StarfitFlowNode updated to handle io in cfs units
jmccreight May 7, 2024
1be30cc
xfail starfit tests for CI pending data decisions
jmccreight May 7, 2024
4bb7327
lint and add geopandas to core dependencies
jmccreight May 7, 2024
6c69fdd
new big sandy notebook with pass-through working
jmccreight May 8, 2024
0dc288f
create graph preprocess function in notebook 06
jmccreight May 8, 2024
d1e5e9b
run pre-commit
jmccreight May 8, 2024
e81b0e4
create graph postprocess function in notebook 06
jmccreight May 8, 2024
acc8057
starfit parameters from conus_istarf and grand sources now give NaTs …
jmccreight May 9, 2024
a40f088
fix starfit parameters from conus_istarf and grand sources now give N…
jmccreight May 9, 2024
9029617
prelimary refactoring of notebook 06 to remove prms_channel_flow_grap…
jmccreight May 9, 2024
1146606
storages and node storages in FlowNode/FlowGraph
jmccreight May 9, 2024
e6fe7ee
minor changes/fixes, some documentation
jmccreight May 10, 2024
d80d2ca
bit more minor changes/fixes, some documentation
jmccreight May 10, 2024
c9bd2b7
fix subtimestep vs full timestep outflows on pass_through_node
jmccreight May 13, 2024
fda480f
subset starfit coupling with mass balance on individual starfit nodes
jmccreight May 15, 2024
1997490
unit conversion hourly
jmccreight May 15, 2024
ef0bad3
starfit with flowgraph daily version working and tested
jmccreight May 18, 2024
08aa37d
fix to starfit flownode hourly calculations
jmccreight May 20, 2024
2a42db8
lint
jmccreight May 20, 2024
8029811
flow graph details re budget and examples; domain plot now handles hr…
jmccreight May 21, 2024
7287740
use pyPRMS for streamflow data used by ObsInNode
jmccreight May 21, 2024
4c744c1
use metadata patches when changing starfit units
jmccreight May 22, 2024
10522dc
global mass budgets drop spatial dimension
jmccreight May 22, 2024
ebdec0b
lint
jmccreight May 22, 2024
bfc400b
fix test_starfit_flow_graph.py
jmccreight May 23, 2024
6b23130
refactor test_starfit to use mean results, ship input and answer data…
jmccreight May 23, 2024
b7fc0f1
lint
jmccreight May 23, 2024
f666425
fix missing starfit input, reduce the length of the tested starfit si…
jmccreight May 23, 2024
421a72b
update codcov action in ci; update hydrology to use "defer" as defaul…
jmccreight May 23, 2024
7f040f6
StarfitNode regression against starfit with hourly/daily sauce; rollb…
jmccreight May 24, 2024
8d121ea
clean up some warnings; lint
jmccreight May 24, 2024
eb93b80
remove shapely version < 2.0 pin
jmccreight Jun 20, 2024
8096dd1
merge upstream/develop
jmccreight Jun 20, 2024
8726bfd
merge upstream/develop
jmccreight Jun 21, 2024
d243e5e
update date notebook 01 to show DomainPlot usage
jmccreight Jun 24, 2024
1500675
progress on docs for FlowGraph
jmccreight Jun 28, 2024
ca2fcec
merge upstream/develop
jmccreight Jun 28, 2024
ce79ccb
update some docs for FlowGraph
jmccreight Jun 29, 2024
6ffbbaa
lint
jmccreight Jun 29, 2024
1efef4a
fix imports and environment.yml
jmccreight Jun 29, 2024
1026307
optional import ipython
jmccreight Jun 29, 2024
804e870
no errors on optional import
jmccreight Jun 29, 2024
6775308
warn on optional import
jmccreight Jun 29, 2024
ec79a8d
update utils/gis_files and add utils/addtl_domain_files.py
jmccreight Jun 30, 2024
c7e33d3
additional fgr domain downloads
jmccreight Jun 30, 2024
093076d
fix display command
jmccreight Jun 30, 2024
2ec2a48
fix display command
jmccreight Jun 30, 2024
f7aa93f
add gis and additional domain file retrieval to ci.yaml
jmccreight Jul 1, 2024
5015376
add gis and additional domain file retrieval to ci_examples.yaml
jmccreight Jul 1, 2024
67f2275
gis and additional domain files touch up
jmccreight Jul 1, 2024
f791c1c
gis and additional domain files touch up part 2
jmccreight Jul 1, 2024
4ae011a
update docs for FlowGraph
jmccreight Jul 1, 2024
5061bf0
update notebooks
jmccreight Jul 1, 2024
6a7b6d5
merge upstream/develop
jmccreight Jul 1, 2024
4ee456a
lint
jmccreight Jul 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ jobs:
pip -V
pip list

- name: Get GIS files for tests
run: |
python pywatershed/utils/gis_files.py

- name: domainless - run tests no requiring domain data
working-directory: autotest
run: pytest -m domainless -n=auto -vv
Expand All @@ -200,7 +204,7 @@ jobs:
run: pytest
-vv
-n=auto
-m domain
-m "not domainless"
--domain=sagehen_5yr
--control_pattern=sagehen_no_cascades.control
--durations=0
Expand All @@ -225,15 +229,15 @@ jobs:
run: pytest
-vv
-n=auto
-m domain
-m "not domainless"
--domain=hru_1
--control_pattern=nhm.control
--durations=0
--cov=pywatershed
--cov-report=xml
--junitxml=pytest_hru_1_nhm.xml

- name: drb_2yr with and without dprst - generate and manage test data
- name: drb_2yr with and without dprst and obsin - generate and manage test data
working-directory: autotest
run: |
python generate_test_data.py \
Expand All @@ -255,7 +259,7 @@ jobs:
run: pytest
-vv
-n=auto
-m domain
-m "not domainless"
--domain=drb_2yr
--control_pattern=nhm.control
--durations=0
Expand All @@ -274,14 +278,30 @@ jobs:
test_prms_below_snow.py
-vv
-n=auto
-m domain
-m "not domainless"
--domain=drb_2yr
--control_pattern=no_dprst
--durations=0
--cov=pywatershed
--cov-report=xml
--junitxml=pytest_drb_2yr_no_dprst.xml

# Specific tests not redundant with dprst
- name: drb_2yr_obsin - pywatershed tests
working-directory: autotest
run: pytest
test_obsin_flow_node.py
-vv
-n=0
-m "not domainless"
--domain=drb_2yr
--control_pattern=nhm_obsin.control
--durations=0
--cov=pywatershed
--cov-report=xml
--junitxml=pytest_drb_2yr_no_dprst.xml


- name: ucb_2yr_nhm - generate and manage test data
working-directory: autotest
run: |
Expand All @@ -298,7 +318,7 @@ jobs:
working-directory: autotest
run: pytest
-vv
-m domain
-m "not domainless"
--domain=ucb_2yr
--control_pattern=nhm.control
--durations=0
Expand Down
14 changes: 8 additions & 6 deletions .github/workflows/ci_examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@ jobs:
compiler: gcc
version: 11

- name: Download GIS files
working-directory: examples
run: |
curl -LO https://github.com/EC-USGS/pywatershed/releases/download/v2022.0.1/pynhm_gis.zip
unzip pynhm_gis.zip

- name: Set environment variables
run: |
echo "PYTHON_VERSION=${{ matrix.python-version }}" >> $GITHUB_ENV
Expand Down Expand Up @@ -78,6 +72,14 @@ jobs:
run: |
python -c "import pywatershed"

- name: Get GIS files for tests
run: |
python pywatershed/utils/gis_files.py

- name: Get additional domain files for notebooks
run: |
python pywatershed/utils/addtl_domain_files.py

- name: Run tests
working-directory: autotest_exs
run: |
Expand Down
8 changes: 8 additions & 0 deletions DISCLAIMER.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [Disclaimer](#disclaimer)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Disclaimer
==========

Expand Down
8 changes: 8 additions & 0 deletions asv_benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [ASV Benchmarking](#asv-benchmarking)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

# ASV Benchmarking

[https://github.com/airspeed-velocity/asv/](https://github.com/airspeed-velocity/asv/)
Expand Down
10 changes: 6 additions & 4 deletions autotest/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ def pytest_generate_tests(metafunc):

control_pattern_list = metafunc.config.getoption("control_pattern")

if (
"domainless" not in metafunc.config.option.markexpr
and "simulation" in metafunc.fixturenames
):
if "domainless" == metafunc.config.option.markexpr:
return

if "simulation" in metafunc.fixturenames:
simulations = collect_simulations(domain_list, control_pattern_list)

# Put --print_ans in the domain fixture as it applies only to the
Expand All @@ -165,3 +165,5 @@ def pytest_generate_tests(metafunc):
metafunc.parametrize(
"simulation", simulations.values(), ids=simulations.keys()
)

return
1 change: 1 addition & 0 deletions autotest/test_budget.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def test_budget(control_simple):
time_unit="D",
description="simple_test",
units="m*3/D",
verbose=False,
)
budget.set(terms)

Expand Down
2 changes: 0 additions & 2 deletions autotest/test_cbh_to_netcdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ def params_and_none(request, simulation, control):
}


@pytest.mark.domain
@pytest.mark.parametrize("var", [var_cases[0]])
def test_cbh_files_to_df(simulation, var, params):
the_file = simulation["dir"] / f"{var}.cbh"
Expand All @@ -96,7 +95,6 @@ def test_cbh_files_to_df(simulation, var, params):
return


@pytest.mark.domain
def test_cbh_file_to_netcdf(simulation, params, tmp_path):
input_files_dict = {
ff.with_suffix("").name: ff for ff in simulation["dir"].glob("*.cbh")
Expand Down
4 changes: 0 additions & 4 deletions autotest/test_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,12 @@ def test_control_advance(control_simple, params_simple):
# )


@pytest.mark.domain
def test_init_load(simulation):
with pytest.warns(RuntimeWarning):
_ = Control.load_prms(simulation["control_file"])
return None


@pytest.mark.domain
def test_deepcopy(simulation):
ctl = Control.load_prms(
simulation["control_file"], warn_unused_options=False
Expand All @@ -178,7 +176,6 @@ def test_deepcopy(simulation):
return None


@pytest.mark.domain
def test_setitem_setattr(simulation):
ctl = Control.load_prms(
simulation["control_file"], warn_unused_options=False
Expand All @@ -204,7 +201,6 @@ def test_setitem_setattr(simulation):
ctl.options = None


@pytest.mark.domain
def test_yaml_roundtrip(simulation, tmp_path):
ctl = Control.load_prms(
simulation["control_file"], warn_unused_options=False
Expand Down
1 change: 0 additions & 1 deletion autotest/test_control_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
)


@pytest.mark.domain
def test_control_read(simulation):
domain_name = simulation["name"].split(":")[0]
if domain_name not in test_answers.keys():
Expand Down
14 changes: 6 additions & 8 deletions autotest/test_netcdf_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def check_vars():
check_budget_sum_vars_params = [False, True, "some"]


@pytest.mark.domain
@pytest.mark.filterwarnings("ignore:Budget for")
@pytest.mark.parametrize(
"budget_sum_param",
Expand Down Expand Up @@ -184,12 +183,12 @@ def test_process_budgets(
for bb in check_budget_sum_vars:
if tt == 0:
# use the output data to figure out the shape
check_dict[pp][bb] = np.zeros(
(
n_time_steps,
model.processes[pp].budget[f"_{bb}"].shape[0],
)
)
shp = model.processes[pp].budget[f"_{bb}"].shape
if len(shp):
shp = shp[0]
else:
shp = 1
check_dict[pp][bb] = np.zeros((n_time_steps, shp))

check_dict[pp][bb][tt, :] = model.processes[pp].budget[
f"_{bb}"
Expand Down Expand Up @@ -245,7 +244,6 @@ def sep_vars(request):
return (request.param[0], request.param[1])


@pytest.mark.domain
def test_separate_together_var_list(
simulation, control, params, tmp_path, sep_vars, check_vars
):
Expand Down
3 changes: 0 additions & 3 deletions autotest/test_netcdf_read.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import pytest

from pywatershed.utils.netcdf_utils import NetCdfRead


@pytest.mark.domain
def test_netcdf(simulation):
variable = "gwres_stor"
output_dir = simulation["output_dir"]
Expand Down
Loading
Loading