Skip to content

Commit

Permalink
Lint: Utils module (#350)
Browse files Browse the repository at this point in the history
1. This PR makes the utils module PyLint compatible and enforces this compatibility through GitHub Actions. 
2. Updates the GitHub Actions testing environment to use the conda environment.yml file for consistency. 
3. Updates the folium map calls in the Pacwave example to align with the latest folium API changes.
  • Loading branch information
ssolson authored Nov 27, 2024
1 parent ca9709f commit 27114e7
Show file tree
Hide file tree
Showing 18 changed files with 689 additions and 388 deletions.
132 changes: 88 additions & 44 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,30 @@ jobs:
auto-update-conda: true
python-version: ${{ env.PYTHON_VER }}
activate-environment: TESTconda
use-only-tar-bz2: true
use-only-tar-bz2: false

- name: Setup Conda environment
- name: Create MHKiT Conda environment
shell: bash -l {0}
run: |
conda install numpy cython pip hdf5 libnetcdf cftime netcdf4 --strict-channel-priority
pip install -e . --force-reinstall
conda env create -f environment.yml
conda activate mhkit-env

- name: Install dependencies
- name: Install testing dependencies
shell: bash -l {0}
run: |
python -m pip install --upgrade pip wheel
pip install coverage pytest coveralls .
conda activate mhkit-env
conda install -y pytest coverage coveralls

- name: Install mhkit
shell: bash -l {0}
run: |
conda activate mhkit-env
pip install -e . --no-deps

- name: Prepare non-hindcast API data
shell: bash -l {0}
run: |
conda activate mhkit-env
pytest mhkit/tests/river/test_io_usgs.py
pytest mhkit/tests/tidal/test_io.py
pytest mhkit/tests/wave/io/test_cdip.py
Expand Down Expand Up @@ -109,23 +116,30 @@ jobs:
auto-update-conda: true
activate-environment: TEST
python-version: ${{ env.PYTHON_VER }}
use-only-tar-bz2: true
use-only-tar-bz2: false

- name: Setup Conda environment
- name: Create MHKiT Conda environment
shell: bash -l {0}
run: |
conda install numpy cython pip pytest hdf5 libnetcdf cftime netcdf4 coverage --strict-channel-priority
pip install -e . --force-reinstall
conda env create -f environment.yml
conda activate mhkit-env

- name: Install dependencies
- name: Install testing dependencies
shell: bash -l {0}
run: |
python -m pip install --upgrade pip wheel
pip install coverage pytest coveralls .
conda activate mhkit-env
conda install -y pytest coverage coveralls

- name: Install mhkit
shell: bash -l {0}
run: |
conda activate mhkit-env
pip install -e . --no-deps

- name: Prepare Wave Hindcast data
shell: bash -l {0}
run: |
conda activate mhkit-env
pytest mhkit/tests/wave/io/hindcast/test_hindcast.py

- name: Upload Wave Hindcast data as artifact
Expand All @@ -151,23 +165,30 @@ jobs:
auto-update-conda: true
activate-environment: TEST
python-version: ${{ env.PYTHON_VER }}
use-only-tar-bz2: true
use-only-tar-bz2: false

- name: Setup Conda environment
- name: Create MHKiT Conda environment
shell: bash -l {0}
run: |
conda install numpy cython pip pytest hdf5 libnetcdf cftime netcdf4 coverage --strict-channel-priority
pip install -e . --no-deps --force-reinstall
conda env create -f environment.yml
conda activate mhkit-env

- name: Install dependencies
- name: Install testing dependencies
shell: bash -l {0}
run: |
python -m pip install --upgrade pip wheel
pip install coverage pytest coveralls .
conda activate mhkit-env
conda install -y pytest coverage coveralls

- name: Install mhkit
shell: bash -l {0}
run: |
conda activate mhkit-env
pip install -e . --no-deps

- name: Prepare Wind Hindcast data
shell: bash -l {0}
run: |
conda activate mhkit-env
pytest mhkit/tests/wave/io/hindcast/test_wind_toolkit.py

- name: Upload Wind Hindcast data as artifact
Expand Down Expand Up @@ -201,21 +222,28 @@ jobs:
python-version: ${{ matrix.python-version }}
use-only-tar-bz2: false

- name: Create and setup Conda environment
- name: Create MHKiT Conda environment
shell: bash -l {0}
run: |
conda install -c conda-forge pytest coverage=7.5.0 coveralls --strict-channel-priority
pip install -e . --force-reinstall
conda env create -f environment.yml
conda activate mhkit-env

- name: Download data from artifact
uses: actions/download-artifact@v4
with:
name: data
path: ~/.cache/mhkit
- name: Install testing dependencies
shell: bash -l {0}
run: |
conda activate mhkit-env
conda install -y pytest coverage coveralls

- name: Install mhkit
shell: bash -l {0}
run: |
conda activate mhkit-env
pip install -e . --no-deps

- name: Run pytest & generate coverage report
shell: bash -l {0}
run: |
conda activate mhkit-env
coverage run --rcfile=.github/workflows/.coveragerc --source=./mhkit/ -m pytest -c .github/workflows/pytest.ini
coverage lcov

Expand Down Expand Up @@ -310,11 +338,23 @@ jobs:
python-version: ${{ matrix.python-version }}
use-only-tar-bz2: false

- name: Setup Conda environment
- name: Create MHKiT Conda environment
shell: bash -l {0}
run: |
conda install -c conda-forge pytest coverage=7.5.0 coveralls --strict-channel-priority
pip install -e . --force-reinstall
conda env create -f environment.yml
conda activate mhkit-env

- name: Install testing dependencies
shell: bash -l {0}
run: |
conda activate mhkit-env
conda install -y pytest coverage coveralls

- name: Install mhkit
shell: bash -l {0}
run: |
conda activate mhkit-env
pip install -e . --no-deps

- name: Download Wave Hindcast data from artifact
uses: actions/download-artifact@v4
Expand All @@ -335,9 +375,10 @@ jobs:
mv ~/.cache/mhkit/wind-hindcast/hindcast/* ~/.cache/mhkit/hindcast/
shell: bash

- name: Install MHKiT and run pytest
- name: Run hindcast pytest
shell: bash -l {0}
run: |
conda activate mhkit-env
coverage run --rcfile=.github/workflows/.coveragehindcastrc -m pytest -c .github/workflows/pytest-hindcast.ini
coverage lcov

Expand Down Expand Up @@ -416,23 +457,25 @@ jobs:
auto-update-conda: true
python-version: '3.11'
activate-environment: TESTconda
use-only-tar-bz2: true
use-only-tar-bz2: false

- name: Install dependencies
- name: Create MHKiT Conda environment
shell: bash -l {0}
run: |
conda install numpy cython pip hdf5 libnetcdf cftime netcdf4 --strict-channel-priority
pip install -e . --force-reinstall
python -m pip install --upgrade pip wheel
pip install nbval jupyter
pip install utm folium
conda env create -f environment.yml
conda activate mhkit-env

- name: Install notebook testing dependencies
shell: bash -l {0}
run: |
conda activate mhkit-env
conda install -y pytest coverage coveralls nbval jupyter utm folium

- name: Ensure Conda environment is activated
- name: Install mhkit
shell: bash -l {0}
run: |
echo "source ~/miniconda3/etc/profile.d/conda.sh" >> ~/.bashrc
echo "conda activate TESTconda" >> ~/.bashrc
source ~/.bashrc
conda activate mhkit-env
pip install -e . --no-deps

- name: Download non-hindcast data
uses: actions/download-artifact@v4
Expand Down Expand Up @@ -470,6 +513,7 @@ jobs:
- name: Run notebook
shell: bash -l {0}
run: |
conda activate mhkit-env
if [[ "${{ matrix.notebook }}" == "examples/metocean_example.ipynb" || "${{ matrix.notebook }}" == "examples/WPTO_hindcast_example.ipynb" ]]; then
if [[ "${{ needs.check-changes.outputs.should-run-hindcast }}" == 'true' ]]; then
jupyter nbconvert --to notebook --execute --inplace --ExecutePreprocessor.timeout=${{ matrix.timeout }} "${{ matrix.notebook }}"
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ jobs:
run: |
pylint mhkit/power/

- name: Run Pylint on mhkit/utils/
run: |
pylint mhkit/utils/

- name: Run Pylint on mhkit/acoustics/
run: |
pylint mhkit/acoustics/
16 changes: 8 additions & 8 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: myenv
name: mhkit-env
channels:
- conda-forge
- defaults
Expand All @@ -12,16 +12,16 @@ dependencies:
- scikit-learn>=1.5.1
- h5py>=3.11.0
- h5pyd>=0.18.0
- netCDF4>=1.6.5
- hdf5>=1.14.3,<1.14.5.0a0
- statsmodels>=0.14.2
- requests
- beautifulsoup4
- numexpr>=2.10.0
- lxml
- bottleneck
- pip:
- netCDF4>=1.7.1.post1
- matplotlib>=3.9.1
- pecos>=0.3.0
- fatpack
- NREL-rex>=0.2.63
- notebook
- pecos>=0.3.0
- notebook
- matplotlib>=3.9.1
- fatpack
- nrel-rex
Loading

0 comments on commit 27114e7

Please sign in to comment.