Skip to content

Commit d401acf

Browse files
committed
WIP API and bindings unit testing; cleaning up; docs, csv support #204, #162, #163, #184, #180, #165, #31
1 parent 3369838 commit d401acf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+9286
-4616
lines changed
Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,94 @@
1-
name: Build and Regression Test
1+
name: Build and Unit Test
22

33
on:
44
push:
55
branches: [ master]
66
# pull_request:
77
# branches: [ master, develop, release ]
88

9+
env:
10+
OMP_NUM_THREADS: 1
11+
BUILD_HOME: build
12+
TEST_HOME: nrtests
13+
PACKAGE_NAME: vcpkg-export-20220826-200052.1.0.0
14+
PKG_NAME: vcpkg-export-20220826-200052
15+
916
jobs:
10-
build:
11-
runs-on: ubuntu-latest
17+
unit_test:
18+
name: Build and unit test
19+
runs-on: windows-2019
20+
environment: testing
21+
defaults:
22+
run:
23+
shell: cmd
24+
25+
steps:
26+
- name: Checkout repo
27+
uses: actions/checkout@v3
28+
29+
- name: Install boost-test
30+
env:
31+
REMOTE_STORE: "https://nuget.pkg.github.com/michaeltryby/index.json"
32+
USERNAME: michaeltryby
33+
run: |
34+
nuget sources add -Name github -Source ${{ env.REMOTE_STORE }} -Username ${{ env.USERNAME }} -Password ${{ secrets.ACCESS_TOKEN }}
35+
nuget install ${{env.PKG_NAME}} -Source github
36+
37+
- name: Build
38+
env:
39+
TOOL_CHAIN_PATH: \scripts\buildsystems\vcpkg.cmake
40+
run: |
41+
cmake -B .\build -DBUILD_TESTS=ON -DCMAKE_TOOLCHAIN_FILE=.\${{env.PACKAGE_NAME}}${{env.TOOL_CHAIN_PATH}} .
42+
cmake --build .\build --config DEBUG
43+
44+
- name: Unit Test
45+
run: ctest --test-dir .\build -C Debug --output-on-failure
46+
47+
48+
reg_test:
49+
name: Build and reg test
50+
runs-on: windows-2019
51+
defaults:
52+
run:
53+
shell: cmd
54+
working-directory: ci-tools/windows
1255

1356
steps:
14-
- uses: actions/checkout@v3
57+
- name: Checkout swmm repo
58+
uses: actions/checkout@v3
59+
60+
- name: Checkout ci-tools repo
61+
uses: actions/checkout@v3
62+
with:
63+
repository: michaeltryby/ci-tools
64+
ref: master
65+
path: ci-tools
66+
67+
- name: Setup python
68+
uses: actions/setup-python@v4
69+
with:
70+
python-version: '3.11'
71+
72+
- name: Install requirements
73+
run: |
74+
python -m pip install --upgrade pip
75+
python -m pip install -r requirements-swmm.txt
76+
77+
- name: Build
78+
run: make.cmd /g "Visual Studio 16 2019"
79+
80+
- name: Before reg test
81+
env:
82+
NRTESTS_URL: https://github.com/USEPA/swmm-nrtestsuite
83+
BENCHMARK_TAG: v2.5.0-dev
84+
run: before-nrtest.cmd ${{ env.BENCHMARK_TAG }}
85+
86+
- name: Run reg test
87+
run: run-nrtests.cmd %GITHUB_RUN_ID%_%GITHUB_RUN_NUMBER%
88+
89+
- name: Upload artifacts
90+
if: ${{ always() }}
91+
uses: actions/upload-artifact@v3
92+
with:
93+
name: build-test-artifacts
94+
path: upload/*.*

.github/workflows/build-and-unit-test.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ env:
1414
PKG_NAME: vcpkg-export-20220826-200052
1515

1616
jobs:
17-
unit_test:
18-
name: Build and unit test
17+
engine_unit_test:
18+
name: Build and unit test computational engine
19+
strategy:
20+
matrix:
21+
os: [windows-latest, ubuntu-latest, macos-13, macos-latest]
22+
python-version: [3.11]
1923
runs-on: windows-2019
2024
environment: testing
2125
defaults:
2226
run:
2327
shell: cmd
24-
2528
steps:
2629
- name: Checkout repo
2730
uses: actions/checkout@v3
@@ -45,7 +48,7 @@ jobs:
4548
run: ctest --test-dir .\build -C Debug --output-on-failure
4649

4750

48-
reg_test:
51+
python_binding_unit_test:
4952
name: Build and reg test
5053
runs-on: windows-2019
5154
defaults:

README.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,40 +46,38 @@ using CMake and the Microsoft Visual Studio C compiler on Windows:
4646
Readme file resides (which should have 'src' as a sub-directory
4747
underneath it).
4848

49-
2. Issue the following command to create the directory for storing the built binaries:
49+
2. Use the following command to create the directory for storing the built binaries:
5050

5151
```bash
5252
mkdir build
53-
cd build
5453
```
5554

56-
3. Then enter the following CMake commands to build the binaries:
55+
3. Then the following CMake commands to build the binaries:
5756

5857
``` bash
59-
cmake -G <compiler> .. -A <platform>
58+
cmake -G <compiler> .. -A <platform> -B .\build
6059
cmake --build . --config Release
6160
```
6261

63-
where `<compiler>` is the name of the Visual Studio compiler being used
62+
where `<compiler>` is the name of the compiler being used
6463
in double quotes (e.g., "Visual Studio 15 2017", "Visual Studio 16 2019",
65-
or "Visual Studio 17 2022") and `<platform>` is Win32 for a 32-bit build
66-
or x64 for a 64-bit build. The resulting engine DLL (swmm5.dll), command
67-
line executable (runswmm.exe), and output processing libraries (swmm-output.dll)
64+
or "Visual Studio 17 2022") and `<platform>` (e.g., Win32 for a 32-bit build
65+
or x64 for a 64-bit build). The resulting engine shared libraries (i.e., swmm5.dll), command line executable (i.e., runswmm.exe), and output processing libraries (i.e., swmm-output.dll)
6866
will appear in the build\Release directory.
6967

7068
For other platforms, such as Linux or MacOS, Step 3 can be replaced with:
7169

7270
```bash
73-
cmake ..
74-
cmake --build .
71+
cmake .
72+
cmake --build .\build
7573
```
7674

7775
The resulting shared object library (libswmm5.so or libswmm5.dylib) and
78-
command line executable (runswmm) will appear in the build directory.
76+
command line executable (runswmm) will be compiled to the build directory.
7977

8078
### Python Bindings (Experimental)
8179

82-
Experimental python bindings for the SWMM API are being developed to support regression and benchmark testing as well as other applications. _**These bindings are still under development and testing and has yet to be cleared through US EPA ORD's official quality assurance review process**_. The exprimental python bindings can be built and installed locally using the following command.
80+
Experimental python bindings for the SWMM API are being developed to support regression and benchmark testing as well as for other applications. _**These bindings are still under development and testing and has yet to be cleared through US EPA ORD's official quality assurance review process**_. The exprimental python bindings can be built and installed locally using the following command.
8381

8482
```bash
8583
cd python

python/MANIFEST.in

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
include LICENSE
22
include README.md
3-
recursive-include *.py
4-
recursive-include *.txt
5-
recursive-include *.md
6-
recursive-include *.pyi
7-
recursive-include *.inp
8-
recursive-include *.pickle
3+
recursive-include . *.py
4+
recursive-include . *.txt
5+
recursive-include . *.md
6+
recursive-include . *.pyi
7+
recursive-include . *.inp
8+
recursive-include . *.pickle
99
recursive-include docs *.rst
1010
recursive-include tests *.csv
1111
global-exclude *.pyc

python/epaswmm/output/_output.pyi

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -267,13 +267,13 @@ class Output:
267267

268268
def __init__(self, output_file: str) -> None:
269269
"""
270-
Constructor to initialize the SWMM output file instance.
270+
Constructor to open the SWMM output file.
271271
272272
:param output_file: Path to the SWMM output file.
273273
:type output_file: str
274274
"""
275275
...
276-
276+
277277
def __enter__(self): # -> Self@Output:
278278
"""
279279
Method to return the SWMM output file instance.
@@ -356,7 +356,7 @@ class Output:
356356
"""
357357
...
358358

359-
def get_time_attribute(self, time_atrribute: int) -> int:
359+
def get_time_attribute(self, time_attribute: TimeAttribute) -> int:
360360
"""
361361
Method to get the temporal attributes of the simulation in the SWMM output file.
362362
@@ -365,7 +365,7 @@ class Output:
365365
"""
366366
...
367367

368-
def get_element_name(self, element_type: int, element_index: int) -> str:
368+
def get_element_name(self, element_type: ElementType, element_index: int) -> str:
369369
"""
370370
Method to get the name of an element in the SWMM output file.
371371
@@ -378,7 +378,7 @@ class Output:
378378
"""
379379
...
380380

381-
def get_element_names(self, element_type: int) -> list:
381+
def get_element_names(self, element_type: ElementType) -> List[str]:
382382
"""
383383
Method to get the names of all elements of a given type in the SWMM output file.
384384
@@ -389,7 +389,7 @@ class Output:
389389
"""
390390
...
391391

392-
def get_subcatchment_timeseries(self, element_index: int, attribute: int, start_date_index: int = ..., end_date_index: int = ...) -> dict:
392+
def get_subcatchment_timeseries(self, element_index: int, attribute: SubcatchAttribute, start_date_index: int = ..., end_date_index: int = ...) -> Dict[datetime, float]:
393393
"""
394394
Method to get the time series data for a subcatchment attribute in the SWMM output file.
395395
@@ -407,7 +407,7 @@ class Output:
407407
"""
408408
...
409409

410-
def get_node_timeseries(self, element_index: int, attribute: int, start_date_index: int = ..., end_date_index: int = ...) -> dict:
410+
def get_node_timeseries(self, element_index: int, attribute: NodeAttribute, start_date_index: int = ..., end_date_index: int = ...) -> Dict[datetime, float]:
411411
"""
412412
Method to get the time series data for a node attribute in the SWMM output file.
413413
@@ -424,7 +424,7 @@ class Output:
424424
"""
425425
...
426426

427-
def get_link_timeseries(self, element_index: int, attribute: int, start_date_index: int = ..., end_date_index: int = ...) -> dict:
427+
def get_link_timeseries(self, element_index: int, attribute: LinkAttribute, start_date_index: int = ..., end_date_index: int = ...) -> Dict[datetime, float]:
428428
"""
429429
Method to get the time series data for a link attribute in the SWMM output file.
430430
@@ -441,7 +441,7 @@ class Output:
441441
"""
442442
...
443443

444-
def get_system_timeseries(self, attribute: int, start_date_index: int = ..., end_date_index: int = ...) -> dict:
444+
def get_system_timeseries(self, attribute: SystemAttribute, start_date_index: int = ..., end_date_index: int = ...) -> Dict[datetime, float]:
445445
"""
446446
Method to get the time series data for a system attribute in the SWMM output file.
447447
@@ -456,7 +456,7 @@ class Output:
456456
"""
457457
...
458458

459-
def get_subcatchment_values_by_time_and_attribute(self, time_index: int, attribute: int) -> dict:
459+
def get_subcatchment_values_by_time_and_attribute(self, time_index: int, attribute: SubcatchAttribute) -> Dict[str, float]:
460460
"""
461461
Method to get the subcatchment values for all subcatchments for a given time index and attribute.
462462
@@ -469,7 +469,7 @@ class Output:
469469
"""
470470
...
471471

472-
def get_node_values_by_time_and_attribute(self, time_index: int, attribute: int) -> dict:
472+
def get_node_values_by_time_and_attribute(self, time_index: int, attribute: NodeAttribute) -> Dict[str, float]:
473473
"""
474474
Method to get the node values for all nodes for a given time index and attribute.
475475
@@ -482,7 +482,7 @@ class Output:
482482
"""
483483
...
484484

485-
def get_link_values_by_time_and_attribute(self, time_index: int, attribute: int) -> dict:
485+
def get_link_values_by_time_and_attribute(self, time_index: int, attribute: LinkAttribute) -> Dict[str, float]:
486486
"""
487487
Method to get the link values for all links for a given time index and attribute.
488488
@@ -495,7 +495,7 @@ class Output:
495495
"""
496496
...
497497

498-
def get_system_values_by_time_and_attribute(self, time_index: int, attribute: int) -> dict:
498+
def get_system_values_by_time_and_attribute(self, time_index: int, attribute: SystemAttribute) -> Dict[str, float]:
499499
"""
500500
Method to get the system values for a given time index and attribute.
501501
@@ -508,7 +508,7 @@ class Output:
508508
"""
509509
...
510510

511-
def get_subcatchment_values_by_time_and_element_index(self, time_index: int, element_index: int) -> dict:
511+
def get_subcatchment_values_by_time_and_element_index(self, time_index: int, element_index: int) -> Dict[str, float]:
512512
"""
513513
Method to get all attributes of a given subcatchment for specified time.
514514
@@ -521,7 +521,7 @@ class Output:
521521
"""
522522
...
523523

524-
def get_node_values_by_time_and_element_index(self, time_index: int, element_index: int) -> dict:
524+
def get_node_values_by_time_and_element_index(self, time_index: int, element_index: int) -> Dict[str, float]:
525525
"""
526526
Method to get all attributes of a given node for specified time.
527527
@@ -534,7 +534,7 @@ class Output:
534534
"""
535535
...
536536

537-
def get_link_values_by_time_and_element_index(self, time_index: int, element_index: int) -> dict:
537+
def get_link_values_by_time_and_element_index(self, time_index: int, element_index: int) -> Dict[str, float]:
538538
"""
539539
Method to get all attributes of a given link for specified time.
540540
@@ -548,7 +548,7 @@ class Output:
548548
"""
549549
...
550550

551-
def get_system_values_by_time(self, time_index: int) -> dict:
551+
def get_system_values_by_time(self, time_index: int) -> Dict[str, float]:
552552
"""
553553
Method to get all attributes of the system for specified time.
554554

0 commit comments

Comments
 (0)