Skip to content

Commit

Permalink
Merge to main branch for v3.0.0 (#356)
Browse files Browse the repository at this point in the history
* Update CONTRIBUTING.md to indicate PRs should be to the new `dev` branch

* Update RELEASING.md to reflect new workflow with the `dev` branch

* Set Default uniform_shift to False (#313)

* Make uniform shift default false and fix test_core

* Allow for non-uniform shift for impedance

* update docstrings (#326)

* damping naming and consistently change radiation damping (#328)

* run CI + codeQL on dev PRs/pushses

* Fix test failures (#330)

* fix tests

* fix pioneer

* actually test power solution for irregular wave (#327)

* Update test_integration with new scaling (#333)

* Phase Realizations Demo and Docs (#315)

* Pioneer tutorial realizations demo

Add frequency array and realization study to beginning of pioneer tutorial

* Update pioneer

* Clean pioneer and update docs

* remove print

* Units

* Update pioneer plots

* Waves before frequencies

* Explain less frequencies

* Minor updates

* Update pioneer

* Merge branch 'dev' of https://github.com/sandialabs/WecOptTool into phases_demo

* issue 321 fd_to_td() bug (#329)

* bug bix : DC and Nyquist frequency should not be devided by two before ifft


* Changed td_to_fd to scale single sided frequency components rather than TD signal

* minor bug fix from issue332 #332

* nodf -> ndof (#334)

* add DOI for Daniel's paper (#336)

* Tutorial cleanup (#339)

* run CI on PRs against dev branch

* revamped tutorial 1, including fix for #293

* more tutorial cleanup and editorial changes

* more cleanup and incorporated changes in #315

* fixed tutorial 2 colormaps

* finishing touches

* reverted a few accidental changes

* fixes as per Jeff's review comments

---------

Co-authored-by: Ryan Coe <[email protected]>

* Utils dev - replaces old utilities PR (#343)

* run CI on PRs against dev branch

* coppied fundamental utility files

* import utilities module

* added utilities funtions to tut1

* added bem plot from utils

* added bem plot from utils

* updated sankey plot

* updated check_radiation_damping

* cleared outputs

* corrected bug

* changed Zi to hydro_impedance to be consistent with our variables name python convention

* PR review edits

* add grid to plots

* removed draft functions in utilities.py

* typo

* Fixed one more typo I found while reviewing Daniel's changes

---------

Co-authored-by: Ryan Coe <[email protected]>
Co-authored-by: Michael Devin <[email protected]>

* Post process docstrings; use loops for multiple realizations (#337)

* post_processing docstrings

- examples
- parameters (order)

* handle multiple phase realizations internally

* Update wecopttool/core.py

* making outputs lists

* Update implementation to function with tutorial 1 for now

* Update tutorials

* Update LUPA

* Make sure same WEC is passed in

* Add test_utilities

Revert "Add test_utilities"

This reverts commit 27399f0.

* Update utilities module

* Update utilities

* Update test_utilities

* Update tutorial 1 utilities call

---------

Co-authored-by: Carlos A. Michelén Ströfer <[email protected]>
Co-authored-by: Carlos A. Michelén Ströfer <[email protected]>
Co-authored-by: jtgrasb <[email protected]>
Co-authored-by: jtgrasb <[email protected]>

* v3.0.0

* Lower tolerance for new test to fix CI failing occasionally

* hyperlinks no longer have formatting, plus other small adjustments (#348)

* Merge to dev, not main (#349)

* Dev version of documentation site (#347)

* added initial file changes based on sphinx_multiversion docs and WEC-Sim implementation

* removed sphinx-multiversion since it is no longer supported and made manual multiversion

* now uses absolute paths, commented out linkcheck for debugging

* fixed docstring errors in utilities module

* updating files again that somehow got reverted

* fixing path in conf.py

* don't run tutorials (will revert later)

* handle file moves correctly, fixed if statement to make other versions appear

* fixed two bugs in versions template

* reverted temp changes, changes latest to main

* switched latest to main

* main branch now in root directory of pages

* fixed URLs with change from last commit

* make other branches visible before building

* switched main branch tag for more testing

* fixed typo

* switched dev branch to an existing branch

* renamed main to latest, changed version.html file name to avoid confusion

* added prints about moving files so Sphinx output isn't misleading

* fixed typo with quotations

* changed versions.html name back because that broke things I guess

* modified contributing documentation to reflect changes

* add logic to remove duplicate 'latest' branch

* Fixed pathing when already on latest

* remove typo

* Troubleshooting complete, switching back to correct branches for deployment

* Removed extra word in docstring

* removed redundant function

* fixed pathing so returns to same file (and fixes tutorial/API docs)

* changed latest branch for demonstration

* switched back latest branch for deployment

* updated with new Capytaine docs URL

* Add warnings when adding inertia and hydrostatic stiffness automatically (#346)

* CI workflow cleanup (#352)

* removed conda environment from workflows since newer capytaine/wavespectra work with Windows

* fixed unnecessary capitalization

* still create CI conda environment to fix Mac environment failures

* added conda env fully back in, push workflow deploys docs, split PR workflow

* conda environment activates again

* mambaforge instead of miniforge

* manual cache reset

* reset to older version of setup-miniconda to troubleshoot

* Specify NumPy version <2.0 since it breaks autograd

---------

Co-authored-by: Carlos A. Michelén Ströfer <[email protected]>
Co-authored-by: jtgrasb <[email protected]>
Co-authored-by: Ryan Coe <[email protected]>
Co-authored-by: Daniel Gaebele <[email protected]>
Co-authored-by: Carlos A. Michelén Ströfer <[email protected]>
Co-authored-by: jtgrasb <[email protected]>
  • Loading branch information
7 people authored Jun 21, 2024
1 parent 31b0361 commit c400ed2
Show file tree
Hide file tree
Showing 18 changed files with 294 additions and 66 deletions.
12 changes: 6 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Community contributions are welcomed! 🎊
## Installation for developers

* It is recommended that you create a *virtual environment*, e.g. using `conda`, `venv`, or similar.
* If you want to build the documentation locally you will also need to install [pandoc](https://pandoc.org/installing.html) and [gifsicle](https://github.com/kohler/gifsicle).
* If you do not have Fortran compilers properly setup in your system, install `capytaine` and `wavesspectra` using `conda`. In this case you will need to have a `conda` virtual environment. This is recommended for *Windows* users since compiling `capytaine` on *Windows* requires [extra steps](https://github.com/capytaine/capytaine/issues/115).
* If you want to build the documentation locally you will also need to install [pandoc](https://pandoc.org/installing.html) and [gifsicle](https://github.com/kohler/gifsicle). On *Windows*, we recommend installing pandoc using `conda` (i.e. `conda install -c conda-forge pandoc`)
* Building using `pip` on *MacOS* requires the manual installation of Fortran compilers, see discussion [here](https://github.com/sandialabs/WecOptTool/discussions/111). For ARM-based Macs, see [issue #324](https://github.com/sandialabs/WecOptTool/issues/324)
* On a ZSH shell (*MacOS*) do `pip install -e .\[dev]` instead of `pip install -e .[dev]` in the instructions below (i.e., escape the opening square bracket).

Using `conda` this looks like:
```bash
conda create -n wecopttool python=3.11
conda create -n wecopttool
conda activate wecopttool
conda install -c conda-forge capytaine wavespectra
conda install -c conda-forge python=3.11 capytaine wavespectra
git clone [email protected]:<YOUR_USER_NAME>/WecOptTool.git
cd WecOptTool
pip install -e .[dev]
Expand Down Expand Up @@ -63,13 +63,13 @@ The documentation is built using [Sphinx](https://www.sphinx-doc.org/en/master/)
The source code (restructured text) is in `./docs/source` and images are in `./docs/source/_static`.
The homepage source code is in `./docs/source/index.rst`.

To build the documentation locally (not required but good check)
To build the documentation locally (not required but good check), go to `./docs/versions.yaml` and change the value of `latest` to be your local branch. Then run:

```bash
python3 docs/build_docs.py
```

The built documentation will be in `./docs/_build` and the homepage is `./docs/_build/index.html`.
The built documentation will be in `./docs/pages` and the homepage is `./docs/pages/index.html`.
To delete, do `python3 docs/clean_docs.py`.

The documentation uses the Jupyter notebook tutorials in the `examples` directory.
Expand Down
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Concise description of the pull request with references to any [issues](https://

## Checklist for PR
- [ ] Authors read the [contribution guidelines](https://github.com/sandialabs/WecOptTool/blob/main/.github/CONTRIBUTING.md)
- [ ] The pull request is from an issue branch (not main) on *your* fork, to the [main branch in WecOptTool](https://github.com/sandialabs/WecOptTool).
- [ ] The pull request is from an issue branch (not main) on *your* fork, to the [dev branch in WecOptTool](https://github.com/sandialabs/WecOptTool/tree/dev).
- [ ] The authors have given the admins edit access
- [ ] All changes adhere to the style guide including PEP8, Docstrings, and Type Hints.
- [ ] Modified the documentation if applicable
Expand Down
142 changes: 142 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Build and Test
# 1. Build and test WecOptTool
# - check that WecOptTool builds on a matrix of OS + Python versions
# - check that all tests pass on the same matrix
# - report the test code coverage
# 2. Check that the documentation builds correctly

on:
pull_request:
branches: [ main, dev ]

jobs:
wecopttool_test:
name: Build (${{ matrix.python-version }}, ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.10", "3.11"] # CHANGE: Python version

steps:
# Checkout the WecOptTool repo
- uses: actions/checkout@v3

# Cache the conda environment >>>
# The cache key includes the OS, the date, the hash of the pyproject.toml file, and the cache number.
# A new cache is created if:
# - this is the first time today that this file is run (date changes)
# - the content of pyproject.toml changes
# - you manually change the value of the CACHE_NUMBER below
# Else the existing cache is used.
- name: Setup Mambaforge
uses: conda-incubator/setup-miniconda@v2
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: test-env
use-mamba: true

# save the date to include in the cache key
- name: Get Date
id: get-date
run: echo "DATE=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_ENV
shell: bash

# create a conda yaml file
# for some reason Windows installs capytaine 1.4 instead of latest.
# CHANGE: Capytaine version
- name: Create environment.yml file
run: |
echo "name: test-env" >> environment.yml;
echo " " >> environment.yml
echo "dependencies:" >> environment.yml
echo " - python=${{ matrix.python-version }}" >> environment.yml
echo " - capytaine" >> environment.yml
echo " - wavespectra" >> environment.yml
cat environment.yml
# use the cache if it exists
- uses: actions/cache@v3
env:
CACHE_NUMBER: 0 # increase to reset cache manually
with:
path: ${{ env.CONDA }}/envs
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ env.DATE }}-${{ hashFiles('pyproject.toml') }}-${{ env.CACHE_NUMBER }}
id: cache

# if cache key has changed, create new cache
- name: Update environment
run: mamba env update -n test-env -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
# <<< Cache the conda environment

# install libglu on ubuntu.
- name: Install libglu
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install libglu1

# install WecOptTool, pytest/coveralls, and gmsh/pygmsh
- name: Install WecOptTool
shell: bash -l {0}
run: |
conda activate test-env
python3 -m pip install --upgrade pip
pip3 install gmsh pygmsh coveralls pytest
pip3 install .
# run all tests & coverage
- name: Run Test
shell: bash -l {0}
run: coverage run -m pytest

# upload coverage data
- name: Upload coverage data to coveralls.io
shell: bash -l {0}
run: coveralls --service=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: ${{ matrix.os }}-${{ matrix.python-version }}
COVERALLS_PARALLEL: true


coveralls:
name: Indicate completion to coveralls.io
needs: wecopttool_test
runs-on: ubuntu-latest
container: python:3-slim
steps:
- name: Finished
run: |
pip3 install --upgrade coveralls
coveralls --finish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


documentation_test:
name: Build documentation
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11' # CHANGE: Python version

- name: Install dependencies
run: sudo apt-get install libglu1 pandoc gifsicle

- name: Install WecOptTool for documentation
shell: bash -l {0}
run: |
python3 -m pip install --upgrade pip
pip3 install wheel coveralls
pip3 install .[dev,geometry]
- name: Build documentation
shell: bash -l {0}
run: |
git fetch --tags
python3 docs/build_docs.py
29 changes: 16 additions & 13 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name: Build and Test
name: Test and Deploy
# 1. Build and test WecOptTool
# - check that WecOptTool builds on a matrix of OS + Python versions
# - check that all tests pass on the same matrix
# - report the test code coverage
# 2. Check that the documentation builds correctly
# 2. Test and deploy the documentation website

on:
push:
branches: [ main, dev ]
pull_request:
branches: [ main, dev ]

jobs:
wecopttool_test:
Expand Down Expand Up @@ -55,7 +53,7 @@ jobs:
echo " " >> environment.yml
echo "dependencies:" >> environment.yml
echo " - python=${{ matrix.python-version }}" >> environment.yml
echo " - capytaine=1.5" >> environment.yml
echo " - capytaine" >> environment.yml
echo " - wavespectra" >> environment.yml
cat environment.yml
Expand Down Expand Up @@ -85,8 +83,7 @@ jobs:
run: |
conda activate test-env
python3 -m pip install --upgrade pip
pip3 install gmsh pygmsh
pip3 install coveralls pytest
pip3 install gmsh pygmsh coveralls pytest
pip3 install .
# run all tests & coverage
Expand All @@ -103,7 +100,6 @@ jobs:
COVERALLS_FLAG_NAME: ${{ matrix.os }}-${{ matrix.python-version }}
COVERALLS_PARALLEL: true


coveralls:
name: Indicate completion to coveralls.io
needs: wecopttool_test
Expand All @@ -117,20 +113,20 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


documentation_test:
name: Build documentation
GitHub_Pages:
name: Build and deploy website
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11' # CHANGE: Python version
python-version: '3.11' # CHANGE: Python version

- name: Install dependencies
run: sudo apt-get install libglu1 pandoc gifsicle

- name: Install WecOptTool for documentation
shell: bash -l {0}
run: |
Expand All @@ -141,4 +137,11 @@ jobs:
- name: Build documentation
shell: bash -l {0}
run: |
git fetch --tags
python3 docs/build_docs.py
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/pages
10 changes: 5 additions & 5 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Release new version
# 1. Publish to TestPyPi and PyPi, sequentially
# 2. Publish to conda-forge
# 3. Deploy documentation website
# 2. Deploy documentation website

on:
release:
Expand All @@ -17,7 +16,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.11' # CHANGE: Python version

- name: Build a binary wheel and a source tarball
run: |
Expand Down Expand Up @@ -47,7 +46,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
python-version: '3.11' # CHANGE: Python version

- name: Install dependencies
run: sudo apt-get install libglu1 pandoc gifsicle
Expand All @@ -62,10 +61,11 @@ jobs:
- name: Build documentation
shell: bash -l {0}
run: |
git fetch --tags
python3 docs/build_docs.py
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/_build/html
publish_dir: ./docs/pages
40 changes: 38 additions & 2 deletions docs/build_docs.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import os
import subprocess
import shutil
import re
import source.make_theory_animations
import yaml

from sphinx.application import Sphinx

import source.make_theory_animations


docs_dir = os.path.dirname(os.path.abspath(__file__))
source_dir = os.path.join(docs_dir, 'source')
conf_dir = source_dir
Expand Down Expand Up @@ -32,6 +38,7 @@ def html():

app.build()


def cleanup():
index_file = os.path.join(html_dir, 'index.html')
with open(index_file, 'r', encoding='utf-8') as f:
Expand All @@ -43,8 +50,37 @@ def cleanup():
'', data, flags=re.DOTALL)
f.write(data2)

if __name__ == '__main__':

def build_doc(version, tag, home_branch):
os.environ['current_version'] = version
subprocess.run(f'git checkout {tag}', shell=True)
subprocess.run(
f"git checkout {home_branch} -- {os.path.join(source_dir, 'conf.py')}", shell=True)
subprocess.run(
f"git checkout {home_branch} -- {os.path.join(docs_dir, 'versions.yaml')}", shell=True)
subprocess.run(
f"git checkout {home_branch} -- {os.path.join(source_dir, '_templates/versions.html')}", shell=True)
source.make_theory_animations
linkcheck()
html()
cleanup()
subprocess.run(
f"git checkout {home_branch}", shell=True)


if __name__ == '__main__':
home_name = 'latest'
with open(os.path.join(docs_dir, 'versions.yaml'), 'r') as v_file:
versions = yaml.safe_load(v_file)
home_branch = versions[home_name]
build_doc(home_name, home_branch, home_branch)
print(f"Moving HTML pages to {os.path.join(docs_dir, 'pages')}...")
shutil.copytree(html_dir, os.path.join(docs_dir, 'pages'))
print('Done.')
for name, tag in versions.items():
if name != home_name:
build_doc(name, tag, home_branch)
print(f"Moving HTML pages to {os.path.join(docs_dir, 'pages', name)}...")
shutil.copytree(html_dir, os.path.join(docs_dir, 'pages', name))
print('Done.')
shutil.rmtree(html_dir)
2 changes: 2 additions & 0 deletions docs/clean_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
source_dir = os.path.join(docs_dir, 'source')
example_dir = os.path.join(source_dir, '_examples')
api_dir = os.path.join(source_dir, 'api_docs')
pages_dir = os.path.join(docs_dir, 'pages')

def clean():
rmtree(example_dir, ignore_errors=True)
rmtree(api_dir, ignore_errors=True)
rmtree(build_dir, ignore_errors=True)
rmtree(pages_dir, ignore_errors=True)

if __name__ == '__main__':
clean()
Loading

0 comments on commit c400ed2

Please sign in to comment.