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

V0.5.0rc1 #111

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
73 changes: 73 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build and Push Image

on:
push:
branches:
- develop
- master
workflow_dispatch:

jobs:
build-and-push:
strategy:
fail-fast: false
matrix:
image: [nereid, redis, celeryworker]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Prepare
id: prep
run: |
DOCKER_IMAGE=${{ secrets.ACR_SERVER }}/nereid/${{ matrix.image }}
VERSION=edge
if [[ $GITHUB_REF == refs/tags/* ]]; then
VERSION=${GITHUB_REF#refs/tags/v}
fi
if [ "${{ github.event_name }}" = "schedule" ]; then
VERSION=nightly
fi
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo "tags: $TAGS"
echo ::set-output name=tags::${TAGS}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"

- name: Login to Azure
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: ${{ secrets.ACR_SERVER }}
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}

- name: Build and Push
id: docker_build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./nereid
file: ./nereid/Dockerfile.multi
target: ${{ matrix.image }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ on:
pull_request:
workflow_dispatch:
schedule:
# every other sunday at noon.
- cron: '0 12 1-7,15-21,29-31 * 0'
# every 2 weeks.
- cron: "0 0 */14 * *"

jobs:
python-test:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
- name: build stack
run: |
docker --version
bash ./scripts/build_deploy.sh
bash ./scripts/build_dev.sh
docker-compose up -d nereid-tests
- name: run tests
run: docker-compose exec -T nereid-tests coverage run -m pytest -xv
Expand Down
12 changes: 6 additions & 6 deletions docker-compose.deploy.images.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
version: '3.7'
version: "3.7"
services:
nereid:
image: sitkacontainers.azurecr.io/ocstormwatertools/nereid_nereid:${NEREID_IMAGE_TAG:-latest}
image: ${ACR_SERVER}/nereid/nereid:${NEREID_IMAGE_TAG:-latest}
celeryworker:
image: sitkacontainers.azurecr.io/ocstormwatertools/nereid_celeryworker:${NEREID_IMAGE_TAG:-latest}
image: ${ACR_SERVER}/nereid/celeryworker:${NEREID_IMAGE_TAG:-latest}
nereid-tests:
image: sitkacontainers.azurecr.io/ocstormwatertools/nereid_nereid-tests:${NEREID_IMAGE_TAG:-latest}
image: ${ACR_SERVER}/nereid/nereid-tests:${NEREID_IMAGE_TAG:-latest}
redis:
image: sitkacontainers.azurecr.io/ocstormwatertools/nereid_redis:${NEREID_IMAGE_TAG:-latest}
image: ${ACR_SERVER}/nereid/redis:${NEREID_IMAGE_TAG:-latest}
flower:
image: sitkacontainers.azurecr.io/ocstormwatertools/nereid_flower:${NEREID_IMAGE_TAG:-latest}
image: ${ACR_SERVER}/nereid/flower:${NEREID_IMAGE_TAG:-latest}
7 changes: 6 additions & 1 deletion make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ if /i %1 == cover-src goto :cover-src
if /i %1 == dev-server goto :dev-server
if /i %1 == restart goto :restart
if /i %1 == lint goto :lint
if /i %1 == login goto :login

:help
echo Commands:
Expand All @@ -31,6 +32,10 @@ goto :eof

set COMPOSE_DOCKER_CLI_BUILD=1

:login
bash scripts/az-login.sh
goto :eof

:test
call make clean
call make restart
Expand Down Expand Up @@ -59,7 +64,7 @@ goto :eof
:coverage
call make clean
call make restart
docker compose exec nereid-tests coverage run -m pytest -x
docker compose exec nereid-tests coverage run --branch -m pytest -x
docker compose exec nereid-tests coverage report -m
goto :eof

Expand Down
2 changes: 1 addition & 1 deletion nereid/nereid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "0.4.3"
__version__ = "0.5.0"
__author__ = "Austin Orr"
__email__ = "aorr@geosyntec.com"
38 changes: 35 additions & 3 deletions nereid/nereid/api/api_v1/models/treatment_facility_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,24 @@
class FacilityBase(BaseModel):
node_id: str
facility_type: str
ref_data_key: str
design_storm_depth_inches: float = Field(..., gt=0)
eliminate_all_dry_weather_flow_override: bool = False
ref_data_key: str = Field(
...,
description=(
"""This attribute is used to determine which nomographs
to reference in order to compute the long-term volume
capture performance of the facility."""
),
)
design_storm_depth_inches: float = Field(
..., gt=0, description="""85th percentile design storm depth in inches"""
)
eliminate_all_dry_weather_flow_override: bool = Field(
False,
description=(
"""Whether to override the dr weather flow capture calculation
and set the performance to 'fully elimates all dry weather flow'. (default=False)"""
),
)


class NTFacility(FacilityBase):
Expand Down Expand Up @@ -77,12 +92,25 @@ class RetentionFacility(OnlineFaciltyBase):
_constructor: str = "retention_facility_constructor"


class RetentionFacilityHSG(OnlineFaciltyBase):
total_volume_cuft: float
area_sqft: float
hsg: str
_constructor: str = "retention_facility_constructor"


class DryWellFacility(OnlineFaciltyBase):
total_volume_cuft: float
treatment_rate_cfs: float
_constructor: str = "dry_well_facility_constructor"


class DryWellFacilityFlowOrVolume(OnlineFaciltyBase):
total_volume_cuft: float
treatment_rate_cfs: float
_constructor: str = "dry_well_facility_flow_or_volume_constructor"


class BioInfFacility(OnlineFaciltyBase):
total_volume_cuft: float
retention_volume_cuft: float
Expand Down Expand Up @@ -154,10 +182,12 @@ class PermPoolFacility(OnlineFaciltyBase):
BioInfFacility,
FlowAndRetFacility,
RetentionFacility,
RetentionFacilityHSG,
TmntFacility,
TmntFacilityWithRetentionOverride,
CisternFacility,
DryWellFacility,
DryWellFacilityFlowOrVolume,
DryWeatherTreatmentLowFlowFacility,
DryWeatherDiversionLowFlowFacility,
LowFlowFacility,
Expand All @@ -171,10 +201,12 @@ class PermPoolFacility(OnlineFaciltyBase):
BioInfFacility,
FlowAndRetFacility,
RetentionFacility,
RetentionFacilityHSG,
TmntFacility,
TmntFacilityWithRetentionOverride,
CisternFacility,
DryWellFacility,
DryWellFacilityFlowOrVolume,
DryWeatherTreatmentLowFlowFacility,
DryWeatherDiversionLowFlowFacility,
LowFlowFacility,
Expand Down
3 changes: 3 additions & 0 deletions nereid/nereid/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
import nereid
from nereid.core.io import load_cfg

with pkg_resources.path("nereid", "__init__.py") as file:
nereid_path = file.parent


class Settings(BaseSettings):
API_V1_STR: str = "/api/v1"
Expand Down
2 changes: 1 addition & 1 deletion nereid/nereid/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Config:
except ValidationError as e:
unvalidated_data["errors"] = "ERROR: " + str(e) + " \n"
model = fallback
valid = model(**unvalidated_data)
valid = model.construct(**unvalidated_data)

return valid

Expand Down
15 changes: 15 additions & 0 deletions nereid/nereid/data/default_data/state/region/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ api_recognize:
validation_fallback: NTFacility
tmnt_performance_facility_type: ¯\_(ツ)_/¯ # wq improvement via retention only

permeable_pavement:
validator: RetentionFacility
validation_fallback: NTFacility
tmnt_performance_facility_type: ¯\_(ツ)_/¯ # wq improvement via retention only

permeable_pavement_hsg:
validator: RetentionFacilityHSG
validation_fallback: NTFacility
tmnt_performance_facility_type: ¯\_(ツ)_/¯ # wq improvement via retention only

bioretention:
validator: BioInfFacility
validation_fallback: NTFacility
Expand Down Expand Up @@ -156,6 +166,11 @@ api_recognize:
validation_fallback: NTFacility
tmnt_performance_facility_type: ¯\_(ツ)_/¯

dry_well_flow_or_volume:
validator: DryWellFacilityFlowOrVolume
validation_fallback: NTFacility
tmnt_performance_facility_type: ¯\_(ツ)_/¯

cistern:
validator: CisternFacility
validation_fallback: NTFacility
Expand Down
4 changes: 2 additions & 2 deletions nereid/nereid/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from nereid.api.api_v1.api import api_router
from nereid.api.api_v1.utils import get_valid_context
from nereid.core.cache import redis_cache
from nereid.core.config import settings
from nereid.core.config import nereid_path, settings

app = FastAPI(title="nereid", version=nereid.__version__, docs_url=None, redoc_url=None)
app.mount("/static", StaticFiles(directory="nereid/static"), name="static")
app.mount("/static", StaticFiles(directory=str(nereid_path / "static")), name="static")


@app.get("/docs", include_in_schema=False)
Expand Down
20 changes: 20 additions & 0 deletions nereid/nereid/src/treatment_facility/constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ def dry_well_facility_constructor(

return result

@staticmethod
def dry_well_facility_flow_or_volume_constructor(
*, total_volume_cuft: float, treatment_rate_cfs: float, **kwargs: dict
) -> Dict[str, Any]:

retention_volume_cuft = total_volume_cuft
retention_ddt_hr = safe_divide(total_volume_cuft, treatment_rate_cfs * 3600)

result = dict(
retention_volume_cuft=retention_volume_cuft,
retention_ddt_hr=retention_ddt_hr,
# We need to override this because dry wells don't perform treatment
# in either wet weather or dry weather, only retention/volume reduction.
# ini_treatment_rate_cfs=treatment_rate_cfs,
retention_rate_cfs=treatment_rate_cfs,
node_type="dry_well_facility",
)

return result

@staticmethod
def bioinfiltration_facility_constructor(
*,
Expand Down
4 changes: 3 additions & 1 deletion nereid/nereid/src/watershed/solve_watershed.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ def solve_node(
)

elif "facility" in node_type:
if any([_type in node_type for _type in ["volume_based", "flow_based",]]):
if any(
[_type in node_type for _type in ["volume_based", "flow_based", "dry_well"]]
):
compute_volume_capture_with_nomograph(data, nomograph_map)
compute_wet_weather_volume_discharge(data)
compute_wet_weather_load_reduction(
Expand Down
Loading