Skip to content

Commit

Permalink
Merge pull request #123 from Geosyntec/v0.6.0
Browse files Browse the repository at this point in the history
v0.6.0rc1
  • Loading branch information
austinorr authored Oct 18, 2022
2 parents c4166af + 07b9d6f commit 1f6fe35
Show file tree
Hide file tree
Showing 42 changed files with 694 additions and 220 deletions.
33 changes: 4 additions & 29 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,19 @@ on:
push:
branches:
- develop
- master
pull_request:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- run: |
sudo apt-get update -y
sudo apt-get install -y graphviz
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.9
- name: Install Linters
run: pip install -r nereid/requirements.txt -r nereid/requirements_tests.txt
- name: Run Linters
run: bash scripts/lint.sh

lint-edge:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9"]
steps:
- run: sudo apt-get install graphviz
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Deps
run: |
pip install --upgrade pip
awk -F"==" '{print $1}' nereid/requirements.txt nereid/requirements_tests.txt > nereid/requirements_edge.txt
pip install -r nereid/requirements_edge.txt
- name: Run Edge Linters
continue-on-error: true
run: bash scripts/lint.sh
- name: Exit
run: exit 0
25 changes: 10 additions & 15 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,15 @@ on:
- master
pull_request:
workflow_dispatch:
schedule:
# twice per month
- cron: "0 10 1,15 * *"

jobs:
python-test:
runs-on: ubuntu-latest
steps:
- run: |
sudo apt-get update -y
sudo apt-get install -y graphviz
- uses: actions/checkout@v2
- run: sudo apt-get install graphviz
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install Deps
Expand All @@ -34,9 +29,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- run: sudo apt-get install graphviz
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install nereid as library
Expand All @@ -50,12 +45,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.8", "3.9"]
python-version: ["3.9", "3.10"]
steps:
- run: sudo apt-get install graphviz
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Edge Deps
Expand All @@ -75,7 +70,7 @@ jobs:
env:
COMPOSE_FILE: docker-stack.yml
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: build stack
run: |
docker --version
Expand All @@ -99,7 +94,7 @@ jobs:
env:
COMPOSE_FILE: docker-stack.yml
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: build stack
run: |
docker --version
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.5.3"
__version__ = "0.6.0-rc1"
__author__ = "Austin Orr"
__email__ = "aorr@geosyntec.com"
6 changes: 4 additions & 2 deletions nereid/nereid/api/api_v1/endpoints_async/reference_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def get_nomograph(
filename: str = "",
type: Optional[str] = None,
) -> Union[Dict[str, Any], Any]:
mapping = load_nomograph_mapping(context)
mapping = load_nomograph_mapping(context) or {}
state, region = context["state"], context["region"]
nomo = mapping.get(filename) or None
if nomo:
Expand Down Expand Up @@ -112,8 +112,10 @@ async def get_reference_data_table(
state, region = context["state"], context["region"]
tables = context.get("project_reference_data", {}).keys()
if table in tables:
data = None
df, msg = load_ref_data(table, context)
data = df.to_dict(orient="records")
if df is not None: # pragma: no branch
data = df.to_dict(orient="records")

else:
detail = f"No such table. Options are {tables}"
Expand Down
6 changes: 4 additions & 2 deletions nereid/nereid/api/api_v1/endpoints_sync/reference_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def get_nomograph(
filename: str = "",
type: Optional[str] = None,
) -> Union[Dict[str, Any], Any]:
mapping = load_nomograph_mapping(context)
mapping = load_nomograph_mapping(context) or {}
state, region = context["state"], context["region"]
nomo = mapping.get(filename) or None
if nomo:
Expand Down Expand Up @@ -114,8 +114,10 @@ async def get_reference_data_table(
state, region = context["state"], context["region"]
tables = context.get("project_reference_data", {}).keys()
if table in tables:
data = None
df, msg = load_ref_data(table, context)
data = df.to_dict(orient="records")
if df is not None: # pragma: no branch
data = df.to_dict(orient="records")

else:
detail = f"No such table. Options are {tables}"
Expand Down
2 changes: 2 additions & 0 deletions nereid/nereid/api/api_v1/models/land_surface_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class Config:


class LandSurfaceBase(BaseModel):
node_type: str = "land_surface"

class Config:
extra = "allow"

Expand Down
82 changes: 69 additions & 13 deletions nereid/nereid/api/api_v1/models/treatment_facility_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,57 @@
from nereid.core.utils import validate_with_discriminator


class FacilityBase(BaseModel):
class _Base(BaseModel):
node_id: str
facility_type: str


class SimpleFacilityBase(_Base):
captured_pct: float = Field(0.0, le=100.0, ge=0.0)
retained_pct: Optional[float] = None
_constructor: str = "simple_facility_constructor"

class Config:
extra = "allow"


class SimpleFacility(SimpleFacilityBase):
@validator("retained_pct", pre=True, always=True, check_fields=False)
def retained_default(cls, v, values):
if v is None:
v = 0.0
else:
assert 0.0 <= v <= 100.0, "retained percent must be between 0.0-100.0"
assert v <= values.get(
"captured_pct", 0.0
), "retained percent must be less than or equal to captured percent"
return v


class SimpleTmntFacility(SimpleFacilityBase):
@validator("retained_pct", pre=True, always=True, check_fields=False)
def retained_default(cls, v):
if v is not None:
assert abs(v) <= 1e-6, "retained percent must be zero."
return 0.0


class SimpleRetFacility(SimpleFacilityBase):
@validator("retained_pct", pre=True, always=True, check_fields=False)
def retained_default(cls, v, values):
if v is not None:
assert v == values.get(
"captured_pct"
), "retained must equal captured for retention BMPs"
return values.get("captured_pct", 0.0)


class FacilityBase(_Base):
ref_data_key: str = Field(
...,
description=(
"""This attribute is used to determine which nomographs
to reference in order to compute the long-term volume
"""This attribute is used to determine which nomographs
to reference in order to compute the long-term volume
capture performance of the facility."""
),
)
Expand All @@ -23,13 +66,13 @@ class FacilityBase(BaseModel):
eliminate_all_dry_weather_flow_override: bool = Field(
False,
description=(
"""Whether to override the dr weather flow capture calculation
"""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):
class NTFacility(_Base):
_constructor: str = "nt_facility_constructor"

class Config:
Expand Down Expand Up @@ -161,18 +204,14 @@ class FlowAndRetFacility(OnlineFaciltyBase):

class CisternFacility(OnlineFaciltyBase):
total_volume_cuft: float
winter_demand_cfs: float
summer_demand_cfs: float
winter_demand_cfs: float = 0.0
summer_demand_cfs: float = 0.0
_constructor: str = "cistern_facility_constructor"


class PermPoolFacility(OnlineFaciltyBase):
pool_volume_cuft: float
pool_drawdown_time_hr: float
treatment_volume_cuft: float
treatment_drawdown_time_hr: float
winter_demand_cfs: float
summer_demand_cfs: float
pool_volume_cuft: float = 0.0
treatment_volume_cuft: float = 0.0
_constructor: str = "perm_pool_facility_constructor"


Expand All @@ -192,6 +231,9 @@ class PermPoolFacility(OnlineFaciltyBase):
DryWeatherDiversionLowFlowFacility,
LowFlowFacility,
FlowFacility,
SimpleFacility,
SimpleTmntFacility,
SimpleRetFacility,
NTFacility,
]

Expand All @@ -211,6 +253,9 @@ class PermPoolFacility(OnlineFaciltyBase):
DryWeatherDiversionLowFlowFacility,
LowFlowFacility,
FlowFacility,
SimpleFacility,
SimpleTmntFacility,
SimpleRetFacility,
NTFacility,
]

Expand All @@ -222,6 +267,17 @@ class PermPoolFacility(OnlineFaciltyBase):
"ref_data_key": "10101200",
"design_storm_depth_inches": 1.45,
},
{
"node_id": 2,
"facility_type": "bioretention_simple",
"captured_pct": 80,
"retained_pct": 20,
},
{
"node_id": 2,
"facility_type": "hydrodynamic_separator_simple",
"captured_pct": 80,
},
{
"node_id": "1",
"facility_type": "dry_extended_detention",
Expand Down
12 changes: 5 additions & 7 deletions nereid/nereid/api/api_v1/models/treatment_site_models.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
from typing import List, Optional

from pydantic import BaseModel
from pydantic import BaseModel, Field

from nereid.api.api_v1.models.response_models import JSONAPIResponse
from nereid.api.api_v1.models.treatment_facility_models import SimpleFacilityBase

## Treatment Site Request Models


class TreatmentSite(BaseModel):
node_id: str
facility_type: str
area_pct: float
captured_pct: float
retained_pct: float
class TreatmentSite(SimpleFacilityBase):
area_pct: float = Field(0.0, le=100.0, ge=0.0)
retained_pct: float = Field(0.0, le=100.0, ge=0.0)
eliminate_all_dry_weather_flow_override: bool = False


Expand Down
2 changes: 1 addition & 1 deletion nereid/nereid/api/api_v1/models/watershed_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@

class Watershed(BaseModel):
graph: Graph
land_surfaces: List[LandSurface]
land_surfaces: Optional[List[LandSurface]] = None
treatment_facilities: Optional[
Union[List[Dict[str, Any]], List[STRUCTURAL_FACILITY_TYPE]]
] = None
Expand Down
1 change: 1 addition & 0 deletions nereid/nereid/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Settings(BaseSettings):
)
VERSION: str = nereid.__version__
DATA_DIRECTORY: Optional[str] = None
LOGLEVEL: str = "INFO"

FORCE_FOREGROUND: bool = False
ENABLE_ASYNC_ROUTES: bool = False
Expand Down
Loading

0 comments on commit 1f6fe35

Please sign in to comment.