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

Add two ctests to RDASApp #3

Merged
merged 4 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 24 additions & 0 deletions .github/workflows/norms.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Coding Norms
on: [push]

jobs:
check_pynorms:
runs-on: ubuntu-latest
name: Check coding norms with pycodestyle

steps:

- name: Install dependencies
run: |
pip install --upgrade pip
pip install pycodestyle
- name: Checkout
uses: actions/checkout@v2
with:
path: RDASApp

- name: Run pycodestyle
run: |
cd $GITHUB_WORKSPACE/RDASApp
pycodestyle -v --config ./.pycodestyle ./ush ./test

58 changes: 58 additions & 0 deletions .github/workflows/unittests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Unit Tests
on: [push, pull_request]

jobs:
ctests:
runs-on: ubuntu-latest
name: Run Unit Tests with ctest

steps:

- name: Install pip dependencies
run: |
pip install --upgrade pip
pip install pycodestyle
pip install netCDF4
pip install xarray

- name: Checkout wxflow
uses: actions/checkout@v3
with:
repository: NOAA-EMC/wxflow
ref: develop
path: wxflow

- name: Install wxflow
run: |
cd wxflow
pip install .

- name: Checkout
uses: actions/checkout@v2
with:
path: RDASApp

- name: Install ecBuild
run: |
git clone https://github.com/ecmwf/ecbuild.git ecbuild
cd ecbuild
git checkout 3.6.1
mkdir bootstrap
cd bootstrap
../bin/ecbuild ..
sudo make install

- name: Configure with cmake
run: |
mkdir $GITHUB_WORKSPACE/build && cd $GITHUB_WORKSPACE/build
cmake -DBUILD_RDASBUNDLE=OFF $GITHUB_WORKSPACE/RDASApp

- name: Build RDASApp
run: |
cd $GITHUB_WORKSPACE/build
make

- name: Run ctest
run: |
cd $GITHUB_WORKSPACE/build
ctest --output-on-failure
6 changes: 6 additions & 0 deletions .pycodestyle
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[pycodestyle]
count = False
ignore = E226,E401,E402,W504
max-line-length = 160
statistics = True
exclude = Experimental
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ endif(BUILD_RDASBUNDLE)
#add_subdirectory(ush)

# Include testing.
#add_subdirectory(test)
add_subdirectory(test)

# Finalize bundle
# ---------------
Expand Down
11 changes: 11 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# create testrun dir
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/test/testrun)

# test for python coding norms
add_test(NAME test_rdasapp_check_python_norms
COMMAND pycodestyle -v --config ./.pycodestyle ./ush ./test
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

add_test(NAME test_rdasapp_gen_3dvar_yaml
COMMAND python3 ${PROJECT_SOURCE_DIR}/test/test_gen_3dvar_yaml.py --input ${PROJECT_SOURCE_DIR}/parm/atm/variational/3dvar_dripcg.yaml --output ${PROJECT_BINARY_DIR}/test/testrun/3dvar_example.yaml
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/test/testrun)
39 changes: 39 additions & 0 deletions test/test_gen_3dvar_yaml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import argparse
import datetime as dt
import os
from wxflow import parse_j2yaml, cast_strdict_as_dtypedict, save_as_yaml
from wxflow import add_to_datetime, to_timedelta, to_datetime

my_dir = os.path.dirname(__file__)
rdas_dir = os.path.join(my_dir, '../')

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--input', type=str, help='Input YAML Template', required=True)
parser.add_argument('-o', '--output', type=str, help='Output YAML File', required=True)
args = parser.parse_args()

os.environ['BERROR_YAML'] = os.path.join(rdas_dir, 'parm', 'atm', 'berror', 'staticb_identity.yaml')
os.environ['OBS_LIST'] = os.path.join(rdas_dir, 'parm', 'atm', 'obs', 'lists', 'rdas_prototype.yaml')
os.environ['OBS_YAML_DIR'] = os.path.join(rdas_dir, 'parm', 'atm', 'obs', 'config')

# let us define a configuration dictionary, note this will be incomplete and an example
config = {
'ATM_WINDOW_BEGIN': to_datetime('2023-11-01T23:30:00Z'),
'ATM_WINDOW_LENGTH': 'PT1H',
'layout_x': 1,
'layout_y': 1,
'npx_ges': 201,
'npy_ges': 151,
'npz_ges': 65,
'current_cycle': to_datetime('2023-11-02T00:00:00Z'),
'npx_anl': 201,
'npy_anl': 151,
'npz_anl': 65,
'DATA': os.path.join(os.path.dirname(args.output)),
'GPREFIX': 'rrfs.t23z.',
'APREFIX': 'rrfs.t00z.',
}

final_config = parse_j2yaml(args.input, config)
save_as_yaml(final_config, args.output)
Loading