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

RTX Code Release (PI-3): Enhancements to Replace and Route to support enterprise hydrofabric and new NWPS api capabilities in near-real time #865

Open
wants to merge 26 commits into
base: ti
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9965f1f
Github code migration (#1)
taddyb Aug 22, 2024
1cd8fe7
Bug Fix: Message queue erroring out and processes not working asynchr…
taddyb Aug 22, 2024
27ed9ee
merging changes (#3)
david-w-martin Aug 22, 2024
37b0f66
Create .gitkeep
taddyb Aug 23, 2024
f52b80c
Added T-Route and formatted NetCDF metadata (#4)
taddyb Aug 23, 2024
874c0b3
Plotting and post-processing function fixes + tests (#5)
david-w-martin Aug 23, 2024
eff5774
Upgrades to RnR: deploying initial states and exception handing in th…
taddyb Aug 24, 2024
2358767
Bug fix: Enhancing plotting and RnR visualizations (#7)
taddyb Aug 25, 2024
34c62ba
Create .gitkeep (#8)
taddyb Aug 25, 2024
3d3db38
deletes
taddyb Aug 25, 2024
40a2924
removing test_data files as they are causing problems (#9)
taddyb Aug 25, 2024
b88549e
merge conflicts
taddyb Aug 25, 2024
9c24c91
Assimilation (#10)
taddyb Aug 26, 2024
e12f77e
Frontend plot/R&R data view (#11)
david-w-martin Aug 27, 2024
ed6cdcf
Changes 20240827 (#12)
david-w-martin Aug 28, 2024
694103a
Code cleanup and Notebooks (#13)
taddyb Aug 28, 2024
8809d32
Update compose.yaml (#14)
taddyb Aug 28, 2024
b68c005
fixed internal 500 error (#15)
taddyb Aug 28, 2024
090d31a
updating plots and logic gates for demoing resutls
taddyb Aug 29, 2024
539ac39
added more print statements and a fix to a copy path (#17)
taddyb Aug 29, 2024
9d1e757
Frontend comment/documentation cleanup (#16)
david-w-martin Aug 29, 2024
a2478b7
Docs bindas (#19)
taddyb Aug 29, 2024
c419858
Initial MVP IaC for RnR (#18)
kevinspurrier Aug 30, 2024
28638c5
Merge branch 'NOAA-OWP:ti' into development
taddyb Sep 3, 2024
acdab76
Documentation (#20)
taddyb Sep 3, 2024
4806f2a
Update README.md
taddyb Sep 3, 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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@
*.tgz binary
*.tar.gz binary
*.gz binary
*.gpkg binary
*.nc binary
57 changes: 57 additions & 0 deletions .github/workflows/pytest_rnr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: PyTest Suite

on: [pull_request]

jobs:
# lint_and_format:
# runs-on: ubuntu-latest

# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-python@v5
# with:
# python-version: "3.11"

# - name: Install pre-commit
# run: |
# python -m pip install pre-commit

# - name: Run pre-commit hooks on all files
# run: |
# pre-commit run --all-files

build:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Set UV_HTTP_TIMEOUT
run: echo "UV_HTTP_TIMEOUT=600" >> $GITHUB_ENV

- name: Install python dependencies and packages
run: |
python -m pip install --upgrade pip
pip install uv
uv venv
source .venv/bin/activate
uv pip install -r Source/RnR/requirements.txt

- name: Echo package versions
run: |
source .venv/bin/activate
uv pip freeze

- name: Run unit tests
run: |
source .venv/bin/activate
cd Source/RnR
pytest -s
24 changes: 23 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,26 @@ terraform.rc
**/buildplan
**/destroyplan

Dev/env.yaml
Dev/env.yaml

###################
# Replace and Route
###################
Source/RnR/.venv
Source/RnR/src/rnr/app/core/config.ini
Source/RnR/mock_db/rnr_schema_dump_20240612.dump
Source/RnR/data
Source/RnR/output
Source/RnR/dist
Source/RnR/notebooks/historical_flood_event
Source/RnR/.Trash*

*.ruff_cache
*.pytest_cache

*.pyc
*.egg-info/
__pycache__/
*.py[cod]
.env
.python-version
80 changes: 80 additions & 0 deletions Source/RnR/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
All notable changes to this project will be documented in this file.
We follow the [Semantic Versioning 2.0.0](http://semver.org/) format.

## 1.0.0 2024-08-29

### Added

- completed the pi-3 demo for OWP. this includes
- the publish/start endpoint
- the full data consumer
- the IaC component


## 0.0.3 2024-08-20

### Added

- migrated to github
- added references to t-route and hfsubset


## 0.0.2 2024-08-12

### Added

- `/static` libraries for JS and CSS
- `/data` directiories now are linked to the

### Deprecated

- Nothing.

### Removed

- Reformatted the working dir to format application under one dir

### Fixed

- Nothing.


## 0.0.2 2024-08-2

### Added

- the `consumer/` folder to handle all data services related to the consumer (similar to the tools/ dir from PI-2)

### Deprecated

- Nothing.

### Removed

- Reformatted the working dir to format application under one dir

### Fixed

- Nothing.


## 0.0.1 2024-07-17

### Added

- Added microservices to read a DB of RFC information
- Commented/documented microservices that read the NWPS API
- Commented/documented microservices that read the DB
- Added relevant tests and project dependencies

### Deprecated

- Nothing.

### Removed

- Nothing.

### Fixed

- Nothing.
15 changes: 15 additions & 0 deletions Source/RnR/Dockerfile.app
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM python:3.11-slim

WORKDIR /app

COPY src/ /app/src

COPY requirements.txt ./
COPY pyproject.toml ./
COPY README.md ./

RUN pip install uv
RUN uv venv
RUN uv pip install --no-cache-dir -r requirements.txt

ENV PYTHONPATH=/app:$PYTHONPATH
11 changes: 11 additions & 0 deletions Source/RnR/Dockerfile.notebook
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM jupyter/minimal-notebook

WORKDIR /app

COPY src /app/src

COPY requirements_notebook.txt .
COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt
RUN pip install --no-cache-dir -r requirements_notebook.txt
7 changes: 7 additions & 0 deletions Source/RnR/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
“Software code created by U.S. Government employees is not subject to copyright
in the United States (17 U.S.C. §105). The United States/Department of Commerce
reserve all rights to seek and obtain copyright protection in countries other
than the United States for Software authored in its entirety by the Department
of Commerce. To this end, the Department of Commerce hereby grants to Recipient
a royalty-free, nonexclusive license to use, copy, and create derivative works
of the Software outside of the United States.”
120 changes: 120 additions & 0 deletions Source/RnR/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Replace and Route

A near real-time system that leverages the NWM data assimilation and channel routing capabilities to extend official flood forecasts issued by RFCs to all river reaches downstream of RFC forecast points by routing the forecasts through the river network to the next downstream forecast point.

Key Features of Replace and Route:
- Deploys a message broker architecture to process incoming RFC forecasts
- Utilizes v20.1 of the enterprise hydrofabric
- Routes forecasted flow to downstream RFC locations
- Uses docker compose to manage architecture
- Uses a jupyter-notebook to view and manage code through a container

<img src="docs/photos/API_spec.png" alt="isolated" width="750"/>

## Installation

1. Install a virtual environment and download dependencies

```shell
pip install uv
uv venv
source .venv/bin/activate
uv pip install -r requirements.txt
```

2. Make sure docker compose is installed on your system
- https://docs.docker.com/compose/install/

3. Start the service
```shell
docker compose up
```

4. View swagger docs for the services

Each of the URLS corresponds to one of the services:

- Publisher app:
- localhost:8000/docs
- Front-end:
- localhost:8001/frontend/v1/plot
- T-route
- localhost:8004/docs
- hfsubset
- localhost:8008/docs
- jupyter
- localhost:8888/lab


## Dependencies

The following containers are utilized
1. RabbitMQ
- rabbitmq:3.13-management
2. Mock DB
- ghcr.io/taddyb33/hydrovis/mock_database:0.0.1
3. HFsubset
- ghcr.io/taddyb33/hfsubset-legacy:0.0.4
4. T-Route
- ghcr.io/taddyb33/t-route-dev:0.0.2
5. Redis
- redis:7.2.5

## Usage

Follow the installation to get to the API services.

To download RFC data based on the mock DB LIDS, run the following command once the DB is up:

```shell
curl -X 'POST' \
'http://localhost:8000/api/v1/rfc/build_rfc_geopackages' \
-H 'accept: application/json' \
-d ''
```

## How to test the software

Run the following command from the project's home dir
```sh
pytest -s
```

## Known issues

- Since there are only 170 locations in the mock DB, this is just a subset of all locations. So, there will be errors if there is no found LID in the DB (This happens oftern)

## Getting help

If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.

## Getting involved

This section should detail why people should get involved and describe key areas you are
currently focusing on; e.g., trying to get feedback on features, fixing certain bugs, building
important pieces, etc.

General instructions on _how_ to contribute should be stated with a link to [CONTRIBUTING](CONTRIBUTING.md).


----

## Open source licensing info
1. [TERMS](TERMS.md)
2. [LICENSE](LICENSE)


----

## Credits and References

Credits to the following developers:
- Tadd Bindas @taddyb33
- David Martin @david-w-martin

Also, thank you to all OWP members / collaborators
- Shawn Crawley
- Fernando Salas
- Derek G
- Nels Frazier (T-Route dev)
- Mike Johnson (Hydrofabric dev)
Loading