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 method option to surface_elevation #126

Merged
merged 7 commits into from
May 10, 2024
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
155 changes: 92 additions & 63 deletions .github/workflows/unix_unit_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,43 @@ jobs:
env:
mhkit-python-dir: "MHKiT-Python"
steps:
- name: Check out MHKiT-MATLAB
uses: actions/checkout@v4

- name: Check out MHKiT-Python
uses: actions/checkout@v4
with:
repository: "MHKiT-Software/MHKiT-Python"
path: ${{env.mhkit-python-dir}}

- name: Install & Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: latest
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: MHKIT_CONDA_ENV
activate-environment: mhkit_conda_env
channels: conda-forge

- name: Setup Python ${{ matrix.python-version }}
- name: "Conda install netcdf4, hdf5"
shell: bash -l {0}
run: |
conda create --name MHKIT_CONDA_ENV python=${{ matrix.python-version }} numpy cython pip pytest hdf5 libnetcdf cftime openssl --strict-channel-priority
conda activate MHKIT_CONDA_ENV
conda install -c conda-forge netcdf4
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config
pip install -e . --no-deps --force-reinstall
conda activate mhkit_conda_env
conda install numpy cython pip pytest hdf5 libnetcdf cftime netcdf4
# conda install netcdf4 hdf5
# export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config

- name: Check out MHKiT-MATLAB
uses: actions/checkout@v4

- name: Check out MHKiT-Python
uses: actions/checkout@v4
with:
repository: "MHKiT-Software/MHKiT-Python"
path: ${{env.mhkit-python-dir}}

- name: pip install mhkit module from source
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
conda activate mhkit_conda_env
pip install -e .
working-directory: ${{env.mhkit-python-dir}}

- name: pip install mhkit-python-utils module from source
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
conda activate mhkit_conda_env
pip install -e .

# Create the cache and add a dummy file
Expand All @@ -70,15 +70,15 @@ jobs:
echo "Hello World" > mhkit_webread_cache/test.txt

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v1
uses: matlab-actions/setup-matlab@v2
with:
release: ${{ matrix.matlab-version }}

# OutOfProcess is required to properly call netcdf/hdf5 and works reliably on macos and ubuntu
- name: Configure MATLAB Python Environment
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
conda activate mhkit_conda_env
printf 'pyenv(Version="%s", ExecutionMode="OutOfProcess")\n' $(python -c "import sys; print(sys.executable)") > run.m

- name: Add MATLAB test commands
Expand All @@ -98,13 +98,13 @@ jobs:
run: cat run.m

- name: Run MATLAB Unit Tests
uses: matlab-actions/run-command@v1
uses: matlab-actions/run-command@v2
with:
command: run
startup-options: -noFigureWindows

- name: Save mhkit_webread_cache directory as an artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
# GitHub Action "Name" of artifact
name: mhkit_webread_cache
Expand All @@ -118,16 +118,16 @@ jobs:

# Expecting 2 * 4 * 7 - (13 * 2) = 30 jobs
matrix:
os: [macos-latest, ubuntu-latest]
os: [macos-13, ubuntu-latest]
python-version: [3.8, 3.9, "3.10", 3.11]
# Note: It is preferred to use an actual release name as opposed to 'latest'
matlab-version: [R2021b, R2022a, R2022b, R2023a, R2023b]
matlab-version: [R2021b, R2022a, R2022b, R2023a, R2023b, R2024a]
exclude:
# cache_population job
- python-version: "3.10"
- python-version: "3.10" # cache_population job
matlab-version: R2022b
os: ubuntu-latest
# Non compatiable MATLAB/Python Versions according to Mathworks
- matlab-version: R2024a # Non compatiable versions of Python and MATLAB
python-version: 3.8
- matlab-version: R2023b
python-version: 3.8
- matlab-version: R2023a
Expand All @@ -154,9 +154,25 @@ jobs:
python-version: "3.10"
- matlab-version: R2020b
python-version: 3.9
# Combinations with failing tests that seem related to GitHub Actions
- matlab-version: R2023b
os: macos-latest
# Specific versions of tests that fail consistently. Most likely due to the GitHub actions environment
- matlab-version: R2024a # Python netcdf4 pip build error: https://github.com/MHKiT-Software/MHKiT-MATLAB/actions/runs/8789749433/job/24123413351
python-version: 3.11
os: macos-13
# - matlab-version: R2024a # Working!
# python-version: "3.10"
# os: macos-13
- matlab-version: R2024a # Java Segfault on Python initialization: https://github.com/MHKiT-Software/MHKiT-MATLAB/actions/runs/8789749433/job/24123411604
python-version: 3.9
os: macos-13
- matlab-version: R2023b # Python netcd4 pip build error: https://github.com/MHKiT-Software/MHKiT-MATLAB/actions/runs/8789749433/job/24123412889
python-version: 3.11
os: macos-13
- matlab-version: R2023b # Java segfault on Python initialization: https://github.com/MHKiT-Software/MHKiT-MATLAB/actions/runs/8789749433/job/24123412352
python-version: "3.10"
os: macos-13
- matlab-version: R2023b # Java segfault on Python initialization: https://github.com/MHKiT-Software/MHKiT-MATLAB/actions/runs/8789749433/job/24123411335
python-version: 3.9
os: macos-13

runs-on: ${{ matrix.os }}

Expand All @@ -172,36 +188,35 @@ jobs:
repository: "MHKiT-Software/MHKiT-Python"
path: ${{env.mhkit-python-dir}}

# - name: Setup Conda
# uses: s-weigand/setup-conda@v1
# with:
# activate-conda: false
# conda-channels: conda-forge

- name: Install & Setup Miniconda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
miniconda-version: latest
auto-update-conda: true
python-version: ${{ matrix.python-version }}
activate-environment: MHKIT_CONDA_ENV
activate-environment: mhkit_conda_env
channels: conda-forge

- name: Setup Python ${{ matrix.python-version }}
# This is necessary to fix any issues with netcdf4 and hdf5 headers
- name: "Conda install netcdf4, hdf5"
shell: bash -l {0}
run: |
conda create --name MHKIT_CONDA_ENV python=${{ matrix.python-version }} numpy cython pip pytest hdf5 libnetcdf cftime netcdf4 --strict-channel-priority
conda activate MHKIT_CONDA_ENV
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config
pip install -e . --no-deps --force-reinstall

# - name: Setup Python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
conda activate mhkit_conda_env
conda install numpy cython pip pytest hdf5 libnetcdf cftime netcdf4
# conda install netcdf4 hdf5
# export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config

# - name: Setup Python ${{ matrix.python-version }}
# shell: bash -l {0}
# run: |
# conda create --name mhkit_conda_env python=${{ matrix.python-version }} numpy cython pip pytest hdf5 libnetcdf cftime netcdf4 --strict-channel-priority
# conda activate mhkit_conda_env
# export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config
# pip install -e . --no-deps --force-reinstall

# - name: Setup MHKiT Dependencies on macOS
# if: ${{ matrix.os == 'macos-13' }}
# run: brew install hdf5 netcdf
# if: ${{ matrix.os == 'macos-latest' }}

# - name: Setup MHKiT Dependencies on ubuntu
# run: sudo apt install libhdf5-serial-dev libnetcdf-dev
Expand Down Expand Up @@ -231,48 +246,57 @@ jobs:
- name: Print Python executable
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
conda activate mhkit_conda_env
python -c "import sys; print(sys.executable)"

- name: Print Python Version
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
conda activate mhkit_conda_env
python --version

- name: pip install mhkit module from source
working-directory: ${{env.mhkit-python-dir}}
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
conda activate mhkit_conda_env
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config
pip install -e .

- name: pip upgrade netcdf4
working-directory: ${{env.mhkit-python-dir}}
shell: bash -l {0}
run: |
conda activate mhkit_conda_env
export PATH="${CONDA_PREFIX}/bin:${CONDA_PREFIX}/Library/bin:$PATH" # so setup.py finds nc-config
pip install --upgrade netcdf4

- name: pip install mhkit-python-utils module from source
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
conda activate mhkit_conda_env
pip install -e .

- name: List installed pip modules
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
conda activate mhkit_conda_env
pip freeze

- name: Print MHKiT-Python Version
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
conda activate mhkit_conda_env
python -c "import mhkit; print(mhkit.__version__)"

- name: Verify MHKiT-Python Operation
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
conda activate mhkit_conda_env
python -c "import mhkit; [ED, AP] = mhkit.river.performance.circular(30); print(ED); print(AP);"

- name: Download mhkit_webread_cache artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: mhkit_webread_cache
path: mhkit_webread_cache
Expand All @@ -282,16 +306,22 @@ jobs:
working-directory: .

- name: Set up MATLAB
uses: matlab-actions/setup-matlab@v2-beta
uses: matlab-actions/setup-matlab@v2
with:
release: ${{ matrix.matlab-version }}

- name: Add Python Dir to Path
shell: bash -l {0}
run: |
conda activate mhkit_conda_env
printf "getenv('path')\nsetenv('path', ['%s;', getenv('path')])\ngetenv('path')\n" $(python -c "import sys; import os; print(os.path.dirname(sys.executable))") >> run.m

# OutOfProcess is required to properly call netcdf/hdf5 and works reliably on macos and ubuntu
- name: Configure MATLAB Python Environment
shell: bash -l {0}
run: |
conda activate MHKIT_CONDA_ENV
printf 'pyenv(Version="%s", ExecutionMode="OutOfProcess")\n' $(python -c "import sys; print(sys.executable)") > run.m
conda activate mhkit_conda_env
printf 'pyenv(Version="%s", ExecutionMode="OutOfProcess")\n' $(python -c "import sys; print(sys.executable)") >> run.m

- name: Add MATLAB test commands
shell: bash
Expand All @@ -316,8 +346,7 @@ jobs:
# select-by-folder: mhkit/tests

- name: Run MATLAB Unit Tests
uses: matlab-actions/run-command@v1
uses: matlab-actions/run-command@v2
with:
command: run
startup-options: -noFigureWindows

Loading