Skip to content

Commit c400ed2

Browse files
michaelcdevincmichelenstroferjtgrasbrgcoedtgaebe
authored
Merge to main branch for v3.0.0 (#356)
* 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]>
1 parent 31b0361 commit c400ed2

18 files changed

+294
-66
lines changed

.github/CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ Community contributions are welcomed! 🎊
44
## Installation for developers
55

66
* It is recommended that you create a *virtual environment*, e.g. using `conda`, `venv`, or similar.
7-
* 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).
8-
* 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).
7+
* 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`)
8+
* 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)
99
* 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).
1010

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

66-
To build the documentation locally (not required but good check)
66+
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:
6767

6868
```bash
6969
python3 docs/build_docs.py
7070
```
7171

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

7575
The documentation uses the Jupyter notebook tutorials in the `examples` directory.

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Concise description of the pull request with references to any [issues](https://
99

1010
## Checklist for PR
1111
- [ ] Authors read the [contribution guidelines](https://github.com/sandialabs/WecOptTool/blob/main/.github/CONTRIBUTING.md)
12-
- [ ] The pull request is from an issue branch (not main) on *your* fork, to the [main branch in WecOptTool](https://github.com/sandialabs/WecOptTool).
12+
- [ ] 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).
1313
- [ ] The authors have given the admins edit access
1414
- [ ] All changes adhere to the style guide including PEP8, Docstrings, and Type Hints.
1515
- [ ] Modified the documentation if applicable

.github/workflows/pr.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Build and Test
2+
# 1. Build and test WecOptTool
3+
# - check that WecOptTool builds on a matrix of OS + Python versions
4+
# - check that all tests pass on the same matrix
5+
# - report the test code coverage
6+
# 2. Check that the documentation builds correctly
7+
8+
on:
9+
pull_request:
10+
branches: [ main, dev ]
11+
12+
jobs:
13+
wecopttool_test:
14+
name: Build (${{ matrix.python-version }}, ${{ matrix.os }})
15+
runs-on: ${{ matrix.os }}
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
20+
python-version: ["3.10", "3.11"] # CHANGE: Python version
21+
22+
steps:
23+
# Checkout the WecOptTool repo
24+
- uses: actions/checkout@v3
25+
26+
# Cache the conda environment >>>
27+
# The cache key includes the OS, the date, the hash of the pyproject.toml file, and the cache number.
28+
# A new cache is created if:
29+
# - this is the first time today that this file is run (date changes)
30+
# - the content of pyproject.toml changes
31+
# - you manually change the value of the CACHE_NUMBER below
32+
# Else the existing cache is used.
33+
- name: Setup Mambaforge
34+
uses: conda-incubator/setup-miniconda@v2
35+
with:
36+
miniforge-variant: Mambaforge
37+
miniforge-version: latest
38+
activate-environment: test-env
39+
use-mamba: true
40+
41+
# save the date to include in the cache key
42+
- name: Get Date
43+
id: get-date
44+
run: echo "DATE=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_ENV
45+
shell: bash
46+
47+
# create a conda yaml file
48+
# for some reason Windows installs capytaine 1.4 instead of latest.
49+
# CHANGE: Capytaine version
50+
- name: Create environment.yml file
51+
run: |
52+
echo "name: test-env" >> environment.yml;
53+
echo " " >> environment.yml
54+
echo "dependencies:" >> environment.yml
55+
echo " - python=${{ matrix.python-version }}" >> environment.yml
56+
echo " - capytaine" >> environment.yml
57+
echo " - wavespectra" >> environment.yml
58+
cat environment.yml
59+
60+
# use the cache if it exists
61+
- uses: actions/cache@v3
62+
env:
63+
CACHE_NUMBER: 0 # increase to reset cache manually
64+
with:
65+
path: ${{ env.CONDA }}/envs
66+
key: conda-${{ runner.os }}--${{ runner.arch }}--${{ env.DATE }}-${{ hashFiles('pyproject.toml') }}-${{ env.CACHE_NUMBER }}
67+
id: cache
68+
69+
# if cache key has changed, create new cache
70+
- name: Update environment
71+
run: mamba env update -n test-env -f environment.yml
72+
if: steps.cache.outputs.cache-hit != 'true'
73+
# <<< Cache the conda environment
74+
75+
# install libglu on ubuntu.
76+
- name: Install libglu
77+
if: matrix.os == 'ubuntu-latest'
78+
run: sudo apt-get install libglu1
79+
80+
# install WecOptTool, pytest/coveralls, and gmsh/pygmsh
81+
- name: Install WecOptTool
82+
shell: bash -l {0}
83+
run: |
84+
conda activate test-env
85+
python3 -m pip install --upgrade pip
86+
pip3 install gmsh pygmsh coveralls pytest
87+
pip3 install .
88+
89+
# run all tests & coverage
90+
- name: Run Test
91+
shell: bash -l {0}
92+
run: coverage run -m pytest
93+
94+
# upload coverage data
95+
- name: Upload coverage data to coveralls.io
96+
shell: bash -l {0}
97+
run: coveralls --service=github
98+
env:
99+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
COVERALLS_FLAG_NAME: ${{ matrix.os }}-${{ matrix.python-version }}
101+
COVERALLS_PARALLEL: true
102+
103+
104+
coveralls:
105+
name: Indicate completion to coveralls.io
106+
needs: wecopttool_test
107+
runs-on: ubuntu-latest
108+
container: python:3-slim
109+
steps:
110+
- name: Finished
111+
run: |
112+
pip3 install --upgrade coveralls
113+
coveralls --finish
114+
env:
115+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116+
117+
118+
documentation_test:
119+
name: Build documentation
120+
runs-on: ubuntu-latest
121+
122+
steps:
123+
- uses: actions/checkout@v3
124+
- uses: actions/setup-python@v4
125+
with:
126+
python-version: '3.11' # CHANGE: Python version
127+
128+
- name: Install dependencies
129+
run: sudo apt-get install libglu1 pandoc gifsicle
130+
131+
- name: Install WecOptTool for documentation
132+
shell: bash -l {0}
133+
run: |
134+
python3 -m pip install --upgrade pip
135+
pip3 install wheel coveralls
136+
pip3 install .[dev,geometry]
137+
138+
- name: Build documentation
139+
shell: bash -l {0}
140+
run: |
141+
git fetch --tags
142+
python3 docs/build_docs.py

.github/workflows/push.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
1-
name: Build and Test
1+
name: Test and Deploy
22
# 1. Build and test WecOptTool
33
# - check that WecOptTool builds on a matrix of OS + Python versions
44
# - check that all tests pass on the same matrix
55
# - report the test code coverage
6-
# 2. Check that the documentation builds correctly
6+
# 2. Test and deploy the documentation website
77

88
on:
99
push:
1010
branches: [ main, dev ]
11-
pull_request:
12-
branches: [ main, dev ]
1311

1412
jobs:
1513
wecopttool_test:
@@ -55,7 +53,7 @@ jobs:
5553
echo " " >> environment.yml
5654
echo "dependencies:" >> environment.yml
5755
echo " - python=${{ matrix.python-version }}" >> environment.yml
58-
echo " - capytaine=1.5" >> environment.yml
56+
echo " - capytaine" >> environment.yml
5957
echo " - wavespectra" >> environment.yml
6058
cat environment.yml
6159
@@ -85,8 +83,7 @@ jobs:
8583
run: |
8684
conda activate test-env
8785
python3 -m pip install --upgrade pip
88-
pip3 install gmsh pygmsh
89-
pip3 install coveralls pytest
86+
pip3 install gmsh pygmsh coveralls pytest
9087
pip3 install .
9188
9289
# run all tests & coverage
@@ -103,7 +100,6 @@ jobs:
103100
COVERALLS_FLAG_NAME: ${{ matrix.os }}-${{ matrix.python-version }}
104101
COVERALLS_PARALLEL: true
105102

106-
107103
coveralls:
108104
name: Indicate completion to coveralls.io
109105
needs: wecopttool_test
@@ -117,20 +113,20 @@ jobs:
117113
env:
118114
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119115

120-
121-
documentation_test:
122-
name: Build documentation
116+
117+
GitHub_Pages:
118+
name: Build and deploy website
123119
runs-on: ubuntu-latest
124120

125121
steps:
126122
- uses: actions/checkout@v3
127123
- uses: actions/setup-python@v4
128124
with:
129-
python-version: '3.11' # CHANGE: Python version
125+
python-version: '3.11' # CHANGE: Python version
130126

131127
- name: Install dependencies
132128
run: sudo apt-get install libglu1 pandoc gifsicle
133-
129+
134130
- name: Install WecOptTool for documentation
135131
shell: bash -l {0}
136132
run: |
@@ -141,4 +137,11 @@ jobs:
141137
- name: Build documentation
142138
shell: bash -l {0}
143139
run: |
140+
git fetch --tags
144141
python3 docs/build_docs.py
142+
143+
- name: Deploy
144+
uses: peaceiris/actions-gh-pages@v3
145+
with:
146+
github_token: ${{ secrets.GITHUB_TOKEN }}
147+
publish_dir: ./docs/pages

.github/workflows/release.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Release new version
22
# 1. Publish to TestPyPi and PyPi, sequentially
3-
# 2. Publish to conda-forge
4-
# 3. Deploy documentation website
3+
# 2. Deploy documentation website
54

65
on:
76
release:
@@ -17,7 +16,7 @@ jobs:
1716
- name: Set up Python
1817
uses: actions/setup-python@v4
1918
with:
20-
python-version: '3.11'
19+
python-version: '3.11' # CHANGE: Python version
2120

2221
- name: Build a binary wheel and a source tarball
2322
run: |
@@ -47,7 +46,7 @@ jobs:
4746
- uses: actions/checkout@v3
4847
- uses: actions/setup-python@v4
4948
with:
50-
python-version: '3.11'
49+
python-version: '3.11' # CHANGE: Python version
5150

5251
- name: Install dependencies
5352
run: sudo apt-get install libglu1 pandoc gifsicle
@@ -62,10 +61,11 @@ jobs:
6261
- name: Build documentation
6362
shell: bash -l {0}
6463
run: |
64+
git fetch --tags
6565
python3 docs/build_docs.py
6666
6767
- name: Deploy
6868
uses: peaceiris/actions-gh-pages@v3
6969
with:
7070
github_token: ${{ secrets.GITHUB_TOKEN }}
71-
publish_dir: ./docs/_build/html
71+
publish_dir: ./docs/pages

docs/build_docs.py

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import os
2+
import subprocess
3+
import shutil
24
import re
3-
import source.make_theory_animations
5+
import yaml
6+
47
from sphinx.application import Sphinx
58

9+
import source.make_theory_animations
10+
11+
612
docs_dir = os.path.dirname(os.path.abspath(__file__))
713
source_dir = os.path.join(docs_dir, 'source')
814
conf_dir = source_dir
@@ -32,6 +38,7 @@ def html():
3238

3339
app.build()
3440

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

46-
if __name__ == '__main__':
53+
54+
def build_doc(version, tag, home_branch):
55+
os.environ['current_version'] = version
56+
subprocess.run(f'git checkout {tag}', shell=True)
57+
subprocess.run(
58+
f"git checkout {home_branch} -- {os.path.join(source_dir, 'conf.py')}", shell=True)
59+
subprocess.run(
60+
f"git checkout {home_branch} -- {os.path.join(docs_dir, 'versions.yaml')}", shell=True)
61+
subprocess.run(
62+
f"git checkout {home_branch} -- {os.path.join(source_dir, '_templates/versions.html')}", shell=True)
4763
source.make_theory_animations
4864
linkcheck()
4965
html()
5066
cleanup()
67+
subprocess.run(
68+
f"git checkout {home_branch}", shell=True)
69+
70+
71+
if __name__ == '__main__':
72+
home_name = 'latest'
73+
with open(os.path.join(docs_dir, 'versions.yaml'), 'r') as v_file:
74+
versions = yaml.safe_load(v_file)
75+
home_branch = versions[home_name]
76+
build_doc(home_name, home_branch, home_branch)
77+
print(f"Moving HTML pages to {os.path.join(docs_dir, 'pages')}...")
78+
shutil.copytree(html_dir, os.path.join(docs_dir, 'pages'))
79+
print('Done.')
80+
for name, tag in versions.items():
81+
if name != home_name:
82+
build_doc(name, tag, home_branch)
83+
print(f"Moving HTML pages to {os.path.join(docs_dir, 'pages', name)}...")
84+
shutil.copytree(html_dir, os.path.join(docs_dir, 'pages', name))
85+
print('Done.')
86+
shutil.rmtree(html_dir)

docs/clean_docs.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
source_dir = os.path.join(docs_dir, 'source')
77
example_dir = os.path.join(source_dir, '_examples')
88
api_dir = os.path.join(source_dir, 'api_docs')
9+
pages_dir = os.path.join(docs_dir, 'pages')
910

1011
def clean():
1112
rmtree(example_dir, ignore_errors=True)
1213
rmtree(api_dir, ignore_errors=True)
1314
rmtree(build_dir, ignore_errors=True)
15+
rmtree(pages_dir, ignore_errors=True)
1416

1517
if __name__ == '__main__':
1618
clean()

0 commit comments

Comments
 (0)