Skip to content

Fix various problems for building and running tests in GitHub CI #90

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 10 commits into from
Jan 16, 2025
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
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
33 changes: 5 additions & 28 deletions .github/workflows/test_suite_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,42 +45,18 @@ jobs:
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: '>=3.7,<3.11'
check-latest: false
token: ***
update-environment: true
allow-prereleases: false
python-version: '3.x'

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

# Generate sounding files
- name: Generate sounding files
run: |
cd YOG_convection/resources/
python3 -m venv venv
source venv/bin/activate
python3 -m pip install -r requirements.txt
python3 sounding_to_netcdf.py
deactivate
cd ../../

# Add Python linter which is ruff
- name: ruff
if: always()
run: |
cd ${{ github.workspace }}
ruff format --diff $(git ls-files *.py)
ruff check --diff $(git ls-files *.py)

# Build the code with cmake
- name: Build test suite
run: |
export TEST_DIR=$(pwd)/tests
cd ${TEST_DIR}
cd tests/
mkdir build
cd build
cmake ..
Expand All @@ -89,4 +65,5 @@ jobs:
# Run the test suites
- name: Test suite
run: |
./test_CAM_interface
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
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