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

Pioneer tutorial updates (empirical impedance model and nonlinear spring) #362

Merged
merged 36 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9e35f0a
Update CONTRIBUTING.md to indicate PRs should be to the new `dev` branch
cmichelenstrofer Apr 1, 2024
db731fe
Update RELEASING.md to reflect new workflow with the `dev` branch
cmichelenstrofer Apr 1, 2024
eed5f7d
Set Default uniform_shift to False (#313)
jtgrasb Apr 1, 2024
b466e6f
update docstrings (#326)
ryancoe Apr 2, 2024
d4f9fc7
damping naming and consistently change radiation damping (#328)
cmichelenstrofer Apr 2, 2024
b4d802f
run CI + codeQL on dev PRs/pushses
ryancoe Apr 2, 2024
775d273
Fix test failures (#330)
jtgrasb Apr 3, 2024
a7bef5f
actually test power solution for irregular wave (#327)
ryancoe Apr 3, 2024
83de96f
Update test_integration with new scaling (#333)
jtgrasb Apr 3, 2024
2abb4fb
Phase Realizations Demo and Docs (#315)
jtgrasb Apr 3, 2024
6fdd660
issue 321 fd_to_td() bug (#329)
dtgaebe Apr 3, 2024
c6f858a
nodf -> ndof (#334)
ryancoe Apr 3, 2024
0b6cd08
add DOI for Daniel's paper (#336)
ryancoe Apr 3, 2024
ea039c5
Tutorial cleanup (#339)
michaelcdevin Apr 23, 2024
b8506d8
Utils dev - replaces old utilities PR (#343)
dtgaebe May 2, 2024
9f2e6ba
Post process docstrings; use loops for multiple realizations (#337)
ryancoe May 3, 2024
98a1feb
v3.0.0
michaelcdevin May 6, 2024
bc38e2e
Lower tolerance for new test to fix CI failing occasionally
michaelcdevin May 7, 2024
ecd7727
hyperlinks no longer have formatting, plus other small adjustments (#…
michaelcdevin May 8, 2024
4792bea
Merge to dev, not main (#349)
michaelcdevin May 9, 2024
ca15bd9
Dev version of documentation site (#347)
michaelcdevin May 15, 2024
d9f8907
updated with new Capytaine docs URL
michaelcdevin May 15, 2024
c218780
Add warnings when adding inertia and hydrostatic stiffness automatica…
jtgrasb May 15, 2024
e545e1c
Add data and update tutorial 4
jtgrasb May 30, 2024
de6e448
CI workflow cleanup (#352)
michaelcdevin Jun 13, 2024
a8485d2
Merge remote-tracking branch 'origin' into dev
michaelcdevin Jun 21, 2024
902c17b
Specify NumPy version <2.0 since it breaks autograd
michaelcdevin Jun 21, 2024
f79ff8b
v3.0.1 (#360)
cmichelenstrofer Jul 11, 2024
f316682
Revert "v3.0.1 (#360)" (#361)
cmichelenstrofer Jul 11, 2024
39c20ef
Update pyproject.toml
cmichelenstrofer Jul 11, 2024
fee2104
Update pioneer tutorial with nl spring and empirical model
jtgrasb Jul 12, 2024
c2af544
Clear outputs
jtgrasb Jul 12, 2024
e253108
Merge branch 'dev' into pioneer_updates
jtgrasb Jul 12, 2024
bd324fc
Merge branch 'dev' of https://github.com/sandialabs/WecOptTool into p…
jtgrasb Aug 13, 2024
40a459d
Consolidate empirical data and fix small issues
jtgrasb Aug 13, 2024
c979223
Remove consolidation file
jtgrasb Aug 13, 2024
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
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 git@github.com:<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
Loading