Skip to content

[WIP] Run tests as part of the CI process #89

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

Merged
merged 36 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4887933
add ci job for UbuntuTestSuite
AdelekeBankole Jan 9, 2025
7a83204
add workflow run
AdelekeBankole Jan 9, 2025
6f5d06c
add steps needed for job
AdelekeBankole Jan 9, 2025
c3cc6c7
add pFUnit to steps required in job
AdelekeBankole Jan 9, 2025
e729a7b
Update .github/workflows/test_suite_ubuntu.yml
AdelekeBankole Jan 13, 2025
3d149eb
Update .github/workflows/test_suite_ubuntu.yml
AdelekeBankole Jan 13, 2025
8841015
Update .github/workflows/test_suite_ubuntu.yml
AdelekeBankole Jan 13, 2025
58098f1
add steps to run test suite
AdelekeBankole Jan 14, 2025
02ba569
Update .github/workflows/test_suite_ubuntu.yml
AdelekeBankole Jan 14, 2025
49f6e5b
add python linter, ruff
AdelekeBankole Jan 14, 2025
9b33b65
add hdf5 in requirements.txt
AdelekeBankole Jan 14, 2025
7e011f1
remove hdf5in requirements.txt
AdelekeBankole Jan 14, 2025
1be238f
add and install hdf5
AdelekeBankole Jan 15, 2025
cf48d06
allow root privileges in getting hdf5
AdelekeBankole Jan 15, 2025
7636480
add and install netcdf lib to dependencies
AdelekeBankole Jan 15, 2025
dfc4958
restrict python version
AdelekeBankole Jan 15, 2025
a6d5ac5
update python run options
AdelekeBankole Jan 15, 2025
3bbf4db
remove pins from dependencies in sounding generation requirements.
jatkinson1000 Jan 15, 2025
e391538
remove ruff from testing suite as covered in the linting checks CI.
jatkinson1000 Jan 15, 2025
ebac2ff
test changing python version.
jatkinson1000 Jan 15, 2025
02902e3
Add SAM sounding file.
jatkinson1000 Jan 15, 2025
1ddcdaf
remove sounding generation from CI workflow as sounding has been uplo…
jatkinson1000 Jan 15, 2025
5053ec8
add netcdf-Fortran to the dependencies installed in the testing CI.
jatkinson1000 Jan 15, 2025
ca2326a
run test from test directory.
jatkinson1000 Jan 15, 2025
ec8a042
Fix ruff errors and pin version to prevent unanticipated issues from …
jatkinson1000 Jan 15, 2025
cee5bd7
Minor tidying of the python CI workflow file.
jatkinson1000 Jan 15, 2025
4b8662b
remove duplicate running of CAM interface test script in test-suite.
jatkinson1000 Jan 16, 2025
0b2ceec
Merge pull request #90 from m2lines/jwa-ci-dependencies-patch
AdelekeBankole Jan 16, 2025
6ce1e13
add exit codes run step
AdelekeBankole Jan 16, 2025
3cc3a8a
add stop 999
AdelekeBankole Jan 17, 2025
ddb302d
try to break code
AdelekeBankole Jan 17, 2025
970b701
remove exit code
AdelekeBankole Jan 17, 2025
11cf9d4
remove the break
AdelekeBankole Jan 17, 2025
50bea02
add YOG convection test in ci
AdelekeBankole Jan 17, 2025
609efb2
remove YOG convection test in ci
AdelekeBankole Jan 17, 2025
04efe1e
Update .github/workflows/test_suite_ubuntu.yml
AdelekeBankole Jan 20, 2025
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
10 changes: 5 additions & 5 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.12
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
python-version: '3.x'

- name: Install dependencies
if: always()
Expand All @@ -27,17 +27,17 @@ jobs:
if: always()
run: ruff check $(git ls-files *.py)

test:
test-python:
needs: code_quality
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Set up Python 3.12
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.12'
python-version: '3.x'

- name: Install dependencies
if: always()
Expand Down
69 changes: 69 additions & 0 deletions .github/workflows/test_suite_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Workflow to run CAM-ML test suite
name: TestSuiteUbuntu

# Controls when the workflow will run
on:
# Triggers the workflow on pushes to the "main" branch, i.e., PR merges
push:
branches: [ "main" ]

# Triggers the workflow on pushes to open pull requests with code changes
pull_request:
paths:
- '.github/workflows/test_suite_ubuntu.yml'
- '**.f90'
- '**.F90'
- '**CMakeLists.txt'
- '**requirements.txt'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Cancel jobs running if new commits are pushed
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

# Workflow run - one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "test-suite-ubuntu"
test-suite-ubuntu:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
fail-fast: false

# These steps represent sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout code
with:
persist-credentials: false
uses: actions/checkout@v4

# Install Python 3
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

# Install dependencies
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libhdf5-dev libnetcdf-dev libnetcdff-dev

# Build the code with cmake
- name: Build test suite
run: |
cd tests/
mkdir build
cd build
cmake ..
cmake --build .

# Run the test suites
- name: Test suite
run: |
cd tests/build
./test_CAM_interface
Binary file added YOG_convection/resources/SAM_sounding.nc
Binary file not shown.
8 changes: 4 additions & 4 deletions YOG_convection/resources/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
certifi==2023.7.22
cftime==1.6.2
netCDF4==1.6.4
numpy==1.21.6
certifi
cftime
netCDF4
numpy
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
torch
netcdf4
ruff
ruff==0.9.1
pytest
2 changes: 1 addition & 1 deletion tests/test_CAM_interface/test_cam_interface.F90
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ subroutine test_rev_var_conv_moist(test_name)
qc_exp = 1.0
qi_exp = 1.0

call assert_array_equal(tabs, tabs_exp, test_name//": tabs")
call assert_array_equal(tabs, tabs_exp + 1000, test_name//": tabs")
call assert_array_equal(qv, qv_exp, test_name//": qv")
call assert_array_equal(qc, qc_exp, test_name//": qc")
call assert_array_equal(qi, qi_exp, test_name//": qi")
Expand Down
3 changes: 3 additions & 0 deletions tests/test_utils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ subroutine print_assert_sp(test_name, is_close, relative_error)
write(*, '(A, " :: [", A, "] maximum relative error = ", E11.4)') pass, trim(test_name), relative_error
else
write(*, '(A, " :: [", A, "] maximum relative error = ", E11.4)') fail, trim(test_name), relative_error
stop 999
end if

end subroutine print_assert_sp
Expand All @@ -44,6 +45,7 @@ subroutine print_assert_dp(test_name, is_close, relative_error)
write(*, '(A, " :: [", A, "] maximum relative error = ", E11.4)') pass, trim(test_name), relative_error
else
write(*, '(A, " :: [", A, "] maximum relative error = ", E11.4)') fail, trim(test_name), relative_error
stop 999
end if

end subroutine print_assert_dp
Expand All @@ -58,6 +60,7 @@ subroutine print_assert_int(test_name, match, abs_error)
write(*, '(A, " :: [", A, "] maximum absolute error = ", I8)') pass, trim(test_name), abs_error
else
write(*, '(A, " :: [", A, "] maximum absolute error = ", I8)') fail, trim(test_name), abs_error
stop 999
end if

end subroutine print_assert_int
Expand Down
4 changes: 2 additions & 2 deletions torch_nets/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ def load_from_netcdf_params(nc_file: str, dtype: str = "float32") -> ANN:
for i, layer in enumerate(
lyr for lyr in model.modules() if isinstance(lyr, nn.Linear)
):
layer.weight.data = torch.tensor(data_set[f"w{i+1}"][:].astype(dtype))
layer.bias.data = torch.tensor(data_set[f"b{i+1}"][:].astype(dtype))
layer.weight.data = torch.tensor(data_set[f"w{i + 1}"][:].astype(dtype))
layer.bias.data = torch.tensor(data_set[f"b{i + 1}"][:].astype(dtype))

return model

Expand Down
Loading