diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 0558cab..6ce1e4c 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -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() @@ -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() diff --git a/.github/workflows/test_suite_ubuntu.yml b/.github/workflows/test_suite_ubuntu.yml index a80ee1f..4519a2c 100644 --- a/.github/workflows/test_suite_ubuntu.yml +++ b/.github/workflows/test_suite_ubuntu.yml @@ -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 .. @@ -89,4 +65,5 @@ jobs: # Run the test suites - name: Test suite run: | - ./test_CAM_interface \ No newline at end of file + cd tests/build + ./test_CAM_interface diff --git a/YOG_convection/resources/SAM_sounding.nc b/YOG_convection/resources/SAM_sounding.nc new file mode 100644 index 0000000..bec6832 Binary files /dev/null and b/YOG_convection/resources/SAM_sounding.nc differ diff --git a/YOG_convection/resources/requirements.txt b/YOG_convection/resources/requirements.txt index 229333d..3058dff 100644 --- a/YOG_convection/resources/requirements.txt +++ b/YOG_convection/resources/requirements.txt @@ -1,4 +1,4 @@ -certifi==2023.7.22 -cftime==1.6.2 -netCDF4==1.6.4 -numpy==1.21.6 +certifi +cftime +netCDF4 +numpy diff --git a/requirements.txt b/requirements.txt index 657bcd6..031e504 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ torch netcdf4 -ruff +ruff==0.9.1 pytest diff --git a/torch_nets/models.py b/torch_nets/models.py index 67bfaf4..2636303 100755 --- a/torch_nets/models.py +++ b/torch_nets/models.py @@ -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