-
Notifications
You must be signed in to change notification settings - Fork 71
NGWPC PI-6 Delivery: Replace and Route #857
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
Open
taddyb
wants to merge
27
commits into
NOAA-OWP:master
Choose a base branch
from
NGWPC:pi_6
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
a4eab3d
PI4 feature integration tests (#8)
taddyb 1ce34c2
PI4 feature unit test updates (#9)
taddyb b902551
Pi4 running troute using HF v2.2 (#10)
taddyb 39e6817
JIRA 5916: Port forecast formatting code into T-Route RnR workspace p…
taddyb df9ee12
updated troute-config to move to pydantic v2 (#12)
taddyb d0e8e05
JIRA 5920: Integrating the RnR domain logic into `troute-rnr` (#13)
taddyb 07dd7d6
JIRA 5917: Replacing the T-Route RnR API with a namespace package (#14)
taddyb acba741
JIRA 5918: Validate t-route runs with testing (#15)
taddyb 2c45996
Jira 5919: Validate T-Route outputs against the max inundation file (…
taddyb e3cdfa6
added uv version of compiler.sh (#17)
taddyb 2b6e024
Patch: remove aws s3 cred references (#18)
taddyb 28e8288
Patch 05162025 (#19)
taddyb 5af0d09
PATCH: remove print from settings
taddyb 9673a1f
Patch 06052025: Adding clearer error statements, and solving WFOs whi…
taddyb 968cbcb
Update main.py (#21)
taddyb fb44ef4
JIRA 6401: Formatting the output.csv file in based on OWP suggestions…
taddyb d70945f
Added a try/catch for t-route (#23)
taddyb fb2a0ce
patch: adding prints for error handling to except value erros
taddyb 35f8906
added finally statement to ensure messages are acknowledged
taddyb 3c36558
adding valueError to skip units other than kcfs
8477ad8
adding try-except format to read_rfc_flows
97316ce
Revert "adding valueError to skip units other than kcfs"
FRahmani368 d4935a4
Revert "Revert "adding valueError to skip units other than kcfs""
FRahmani368 aea3120
Revert "adding valueError to skip units other than kcfs"
FRahmani368 07200af
Revert " adding try-except format to read_rfc_flows"
FRahmani368 78a44bc
patch: added ValueError handling for incorrect stage
taddyb 23deac4
fix: removed setuptools-scm from config pyproject as builds are faili…
taddyb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,3 +79,5 @@ bower_components/ | |
| .grunt/ | ||
| src/vendor/ | ||
| dist/ | ||
|
|
||
| build/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v4.6.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| files: ^src/troute-rnr/ | ||
| - id: end-of-file-fixer | ||
| files: ^src/troute-rnr/ | ||
| - id: check-yaml | ||
| files: ^src/troute-rnr/ | ||
| - id: debug-statements | ||
| files: ^src/troute-rnr/ | ||
|
|
||
| - repo: https://github.com/astral-sh/ruff-pre-commit | ||
| rev: v0.11.5 | ||
| hooks: | ||
| - id: ruff | ||
| args: ["--fix", "--config=src/troute-rnr/pyproject.toml"] | ||
| files: ^src/troute-rnr/ | ||
| - id: ruff-format | ||
| files: ^src/troute-rnr/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| #TODO add options for clean/noclean, make/nomake, cython/nocython | ||
| #TODO include instuctions on blowing away entire package for fresh install e.g. rm -r ~/venvs/mesh/lib/python3.6/site-packages/troute/* | ||
| #set root folder of github repo (should be named t-route) | ||
| REPOROOT=`pwd` | ||
| #For each build step, you can set these to true to make it build | ||
| #or set it to anything else (or unset) to skip that step | ||
| build_mc_kernel=true | ||
| build_diffusive_tulane_kernel=true | ||
| build_reservoir_kernel=true | ||
| build_framework=true | ||
| build_routing=true | ||
| build_config=true | ||
| build_nwm=true | ||
|
|
||
| if [ -z "$F90" ] | ||
| then | ||
| export F90="gfortran" | ||
| echo "using F90=${F90}" | ||
| fi | ||
| if [ -z "$CC" ] | ||
| then | ||
| export CC="gcc" | ||
| echo "using CC=${CC}" | ||
| fi | ||
|
|
||
| #preserve old/default behavior of installing packages with -e | ||
| WITH_EDITABLE=true | ||
| if [ "$1" == 'no-e' ] | ||
| then | ||
| WITH_EDITABLE=false | ||
| fi | ||
|
|
||
| #if you have custom static library paths, uncomment below and export them | ||
| #export LIBRARY_PATH=<paths>:$LIBRARY_PATH | ||
| #if you have custom dynamic library paths, uncomment below and export them | ||
| #export LD_LIBRARY_PATHS=<paths>:$LD_LIBRARY_PATHS | ||
| if [ -z "$NETCDF" ] | ||
| then | ||
| export NETCDFINC=/usr/include/openmpi-x86_64/ | ||
| # set alternative NETCDF variable include path, for example for WSL | ||
| # (Windows Subsystems for Linux). | ||
| # | ||
| # EXAMPLE USAGE: export NETCDFALTERNATIVE=$HOME/.conda/envs/py39/include/ | ||
| # (before ./compiler.sh) | ||
| if [ -n "$NETCDFALTERNATIVE" ] | ||
| then | ||
| echo "using alternative NETCDF inc ${NETCDFALTERNATIVE}" | ||
| export NETCDFINC=$NETCDFALTERNATIVE | ||
| fi | ||
| else | ||
| export NETCDFINC="${NETCDF}" | ||
| fi | ||
| echo "using NETCDFINC=${NETCDFINC}" | ||
|
|
||
| if [[ "$build_mc_kernel" == true ]]; then | ||
| #building reach and resevoir kernel files .o | ||
| cd $REPOROOT/src/kernel/muskingum/ | ||
| make clean | ||
| make || exit | ||
| make install || exit | ||
| fi | ||
|
|
||
| if [[ "$build_diffusive_tulane_kernel" == true ]]; then | ||
| #building reach and resevoir kernel files .o | ||
| cd $REPOROOT/src/kernel/diffusive/ | ||
| make clean | ||
| make diffusive.o | ||
| make pydiffusive.o | ||
| make chxsec_lookuptable.o | ||
| make pychxsec_lookuptable.o | ||
| make install || exit | ||
| fi | ||
|
|
||
| if [[ "$build_reservoir_kernel" == true ]]; then | ||
| cd $REPOROOT/src/kernel/reservoir/ | ||
| make clean | ||
| #make NETCDFINC=`nc-config --includedir` || exit | ||
| #make binding_lp.a | ||
| #make install_lp || exit | ||
| make | ||
| make install_lp || exit | ||
| make install_rfc || exit | ||
|
|
||
| fi | ||
|
|
||
| if [[ "$build_framework" == true ]]; then | ||
| #creates troute package | ||
| cd $REPOROOT/src/troute-network | ||
| rm -rf build | ||
|
|
||
| if [[ ${WITH_EDITABLE} == true ]]; then | ||
| uv pip install --no-build-isolation --config-setting='--build-option=--use-cython' --editable . --config-setting='editable_mode=compat' || exit | ||
| else | ||
| uv pip install --no-build-isolation --config-setting='--build-option=--use-cython' . || exit | ||
| fi | ||
| fi | ||
|
|
||
| if [[ "$build_routing" == true ]]; then | ||
| #updates troute package with the execution script | ||
| cd $REPOROOT/src/troute-routing | ||
| rm -rf build | ||
|
|
||
| if [[ ${WITH_EDITABLE} == true ]]; then | ||
| uv pip install --no-build-isolation --config-setting='--build-option=--use-cython' --editable . --config-setting='editable_mode=compat' || exit | ||
| else | ||
| uv pip install --no-build-isolation --config-setting='--build-option=--use-cython' . || exit | ||
| fi | ||
| fi | ||
|
|
||
| if [[ "$build_config" == true ]]; then | ||
| #updates troute package with the execution script | ||
| cd $REPOROOT/src/troute-config | ||
| if [[ ${WITH_EDITABLE} == true ]]; then | ||
| uv pip install --editable . || exit | ||
| else | ||
| uv pip install . || exit | ||
| fi | ||
| fi | ||
|
|
||
| if [[ "$build_nwm" == true ]]; then | ||
| #updates troute package with the execution script | ||
| cd $REPOROOT/src/troute-nwm | ||
| if [[ ${WITH_EDITABLE} == true ]]; then | ||
| uv pip install --editable . || exit | ||
| else | ||
| uv pip install . || exit | ||
| fi | ||
| fi | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # Dockerfile.Notebook | ||
|
|
||
| This document describes the Docker setup for running JupyterLab with mounted volumes for development and analysis. | ||
|
|
||
| ## Container Overview | ||
|
|
||
| The container provides a JupyterLab environment with: | ||
| - Python environment for data analysis | ||
| - Web interface accessible via port 8000 | ||
|
|
||
| This container is a great way to run examples and integrated tests | ||
|
|
||
| ## Docker Configuration | ||
|
|
||
| ### Dockerfile | ||
| The Dockerfile sets up: | ||
| - Base Python environment | ||
| - JupyterLab installation | ||
| - Volume mount points for data and code | ||
| - Port 8000 exposed for web interface | ||
| - Working directory configuration | ||
|
|
||
| ### Getting Started | ||
|
|
||
| Build: | ||
| ```bash | ||
| docker build -t troute-notebook -f docker/Dockerfile.notebook . | ||
| ``` | ||
|
|
||
| Run: | ||
| ```bash | ||
| docker run -p 8000:8000 troute-notebook | ||
| ``` | ||
|
|
||
| Then, take the URL from the output and put that into your browser. An example one is below: | ||
| ``` | ||
| http://127.0.0.1:8000/lab?token=<token> | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| FROM rockylinux:9.2 as rocky-base | ||
| RUN yum install -y epel-release | ||
| RUN yum install -y netcdf netcdf-fortran netcdf-fortran-devel netcdf-openmpi | ||
|
|
||
| RUN yum install -y git cmake python python-devel pip | ||
|
|
||
| WORKDIR "/t-route/" | ||
|
|
||
| COPY . /t-route/ | ||
|
|
||
| RUN ln -s /usr/lib64/gfortran/modules/netcdf.mod /usr/include/openmpi-x86_64/netcdf.mod | ||
|
|
||
| ENV VIRTUAL_ENV=/opt/venv | ||
| RUN python3 -m venv $VIRTUAL_ENV | ||
|
|
||
| # Equivalent to source /opt/venv/bin/activate | ||
| ENV PATH="$VIRTUAL_ENV/bin:$PATH" | ||
|
|
||
| RUN python -m pip install . | ||
| RUN python -m pip install .[jupyter] | ||
| RUN python -m pip install .[test] | ||
|
|
||
| RUN ./compiler.sh no-e | ||
|
|
||
| EXPOSE 8000 | ||
|
|
||
| # increase max open files soft limit | ||
| RUN ulimit -n 10000 | ||
| CMD ["jupyter", "lab", "--ip=0.0.0.0", "--port=8000", "--no-browser", "--allow-root"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| [project] | ||
| name = "troute_project" | ||
| authors = [ | ||
| {name = "DongHa Kim", email = "dongha.kim@noaa.gov"}, | ||
| {name = "Sean Horvath", email = "sean.horvath@noaa.gov"}, | ||
| {name = "Amin Torabi", email = "amin.torabi@noaa.gov"}, | ||
| {name = "Zach Jurgen", email = "jurgen.zach@noaa.gov"}, | ||
| {name = "Austin Raney", email = "austin.raney@noaa.gov"}, | ||
| ] | ||
| dynamic = ["version", "dependencies"] | ||
|
|
||
| [tool.setuptools.dynamic] | ||
| dependencies = {file = ["requirements.txt"]} | ||
|
|
||
| [project.optional-dependencies] | ||
| test = [ | ||
| "pytest==8.3.2", | ||
| "bmipy==2.0.0", | ||
| ] | ||
|
|
||
| jupyter = [ | ||
| "contextily==1.6.0", | ||
| "matplotlib>=3.7.0,<3.8.0", | ||
| "ipykernel>=6.29.0,<7.0.0", | ||
| "jupyterlab>=3.6.7,<4.0.0", | ||
| "xarray>=2024.1.1", | ||
| "matplotlib-inline>=0.1.6" | ||
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import os | ||
|
|
||
| from contextlib import contextmanager | ||
| from pathlib import Path | ||
|
|
||
|
|
||
| @contextmanager | ||
| def temporarily_change_dir(path: Path): | ||
| """Temporarily changes the current working directory | ||
|
|
||
| This context manager changes the current working directory to the specified path, | ||
| yields control back to the caller, and then changes back to the original directory | ||
| when exiting the context | ||
|
|
||
| Parameters | ||
| ---------- | ||
| path : Path | ||
| The path to temporarily change the current working directory to | ||
|
|
||
| Yields | ||
| ------ | ||
| None | ||
| """ | ||
| original_cwd = Path.cwd() | ||
| if original_cwd != path: | ||
| os.chdir(path) | ||
| try: | ||
| yield | ||
| finally: | ||
| if original_cwd != path: | ||
| os.chdir(original_cwd) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| from pathlib import Path | ||
| from typing import Any, Dict, List, Tuple | ||
|
|
||
| import pytest | ||
| import yaml | ||
| from _pytest.fixtures import FixtureRequest | ||
|
|
||
|
|
||
| def find_config_files() -> List[Path]: | ||
| """Finds all `.yaml` configuration files within specified directories | ||
|
|
||
| Returns | ||
| ------- | ||
| List[Path] | ||
| A list of Path objects pointing to each valid configuration | ||
| """ | ||
| test_dir = Path(__file__).parents[3] / "test" # Searching for the t-route/test dir | ||
| target_dirs = ["LowerColorado_TX", "LowerColorado_TX_v4", "LowerColorado_TX_HYFeatures_v22", "unit_test_hyfeature"] | ||
| files = [] | ||
| for dir_name in target_dirs: | ||
| files.extend(list((test_dir / dir_name).glob("*.yaml"))) | ||
| return files | ||
|
|
||
|
|
||
| @pytest.fixture(params=find_config_files()) | ||
| def config_data(request: FixtureRequest) -> Tuple[Path, Dict[str, Any]]: | ||
| """A fixture for loading yaml files into python dictionary mappings | ||
|
|
||
| Parameters | ||
| ---------- | ||
| request : FixtureRequest | ||
| The pytest request object, containing the current parameter value | ||
|
|
||
| Returns | ||
| ------- | ||
| Tuple[Path, Dict[str, Any]] | ||
| A tuple containing the path to the YAML file and the loaded data as a dictionary | ||
| """ | ||
| data = yaml.load(request.param.read_text(), Loader=yaml.Loader) | ||
| return request.param, data |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest keeping a single "compiler" script and simply adding an option to switch between python installer utilities.