Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into ptfm_updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dzalkind committed Nov 3, 2023
2 parents d2420e6 + 8e57ab0 commit a2313a6
Show file tree
Hide file tree
Showing 93 changed files with 12,212 additions and 11,957 deletions.
100 changes: 74 additions & 26 deletions .github/workflows/CI_WISDEM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,31 @@ on: [push, pull_request]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
name: Build (${{ matrix.os }} Python ${{ matrix.python-version }})
build_conda:
name: Conda Build-Test (${{ matrix.os }} Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -l {0}

shell: bash -el {0}

strategy:
fail-fast: False
matrix:
os: [ubuntu-latest, windows-latest]
os: [ubuntu-latest, windows-latest] #macos-latest,
python-version: ["3.9", "3.10", "3.11"]

steps:
- name: checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4

# Official way to do miniconda, but it messes with the worker environment and shell
- name: Install miniconda
- name: Install conda/mamba
uses: conda-incubator/setup-miniconda@v2
# https://github.com/marketplace/actions/setup-miniconda
with:
miniconda-version: "latest"
channels: conda-forge
# To use mamba, uncomment here, comment out the miniforge line
#mamba-version: "*"
miniforge-version: "latest"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: environment.yml
Expand All @@ -41,49 +40,54 @@ jobs:
- name: Add dependencies ubuntu specific
if: false == contains( matrix.os, 'windows')
run: |
conda install -y petsc4py mpi4py gfortran
conda info -e
conda install -y petsc4py gfortran
# Install dependencies of WISDEM specific to windows
- name: Add dependencies windows specific
if: contains( matrix.os, 'windows')
run: |
conda install -y m2w64-toolchain libpython
# Debugging session
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
- name: Debug config
run: |
conda list
which -a gfortran
which pip
# Install WISDEM with setup
# Note: For some reason, pip --no-deps doesn't find conda packages and downloads everything
- name: Install WISDEM with setup
run: |
python setup.py develop
python setup.py install
# Install WISDEM with pip
- name: Install WISDEM with pip for Unix
if: false == contains( matrix.os, 'windows')
run: |
rm -rf meson_build
pip install -vv --no-deps -e .
#- name: Install WISDEM with pip for Unix
# if: false == contains( matrix.os, 'windows')
# run: |
# python setup.py install

# Install WISDEM with pip
#- name: Install WISDEM with pip for Windows
# if: contains( matrix.os, 'windows')
# run: |
# pip install -vv --no-deps --global-option --compiler=unix .
# python setup.py install

# Debugging session
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3

# Run all tests
- name: Run tests
if: contains( matrix.os, 'ubuntu')
if: false == contains( matrix.os, 'windows')
run: |
pytest --cov=wisdem
pytest -p no:warnings --disable-warnings --cov=wisdem
# Run limited test on WINDOWS
- name: Add dependencies windows specific
- name: Limited Windows test
if: contains( matrix.os, 'windows')
run: |
cd wisdem/test/test_gluecode
pytest test_g*
pytest -p no:warnings --disable-warnings test_g*
# Run coveralls
- name: Run coveralls
Expand All @@ -94,3 +98,47 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
coveralls --service=github
build_pip:
name: Pip Build-Test (${{ matrix.os }} Python ${{ matrix.python-version }})
runs-on: ${{ matrix.os }}

defaults:
run:
shell: bash -el {0}

strategy:
fail-fast: False
matrix:
os: [ubuntu-latest] #, windows-latest, macos-latest,
python-version: ["3.10"]

steps:
- name: Setup GNU Fortran
uses: awvwgk/setup-fortran@v1
#with:
# compiler: intel-classic

- name: checkout repository
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
id: cp
with:
python-version: ${{ matrix.python-version }}
update-environment: true

# Install WISDEM with setup
# Note: For some reason, pip --no-deps doesn't find conda packages and downloads everything
- name: Install WISDEM with setup
run: |
'${{ steps.cp.outputs.python-path }}' -m pip install --upgrade pip install pytest
'${{ steps.cp.outputs.python-path }}' -m pip install -vv .
# Run limited tests
- name: Limited test
run: |
cd wisdem/test/test_gluecode
pytest -p no:warnings --disable-warnings test_g*
66 changes: 66 additions & 0 deletions .github/workflows/Publish_WISDEM.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build and upload to PyPI
# https://github.com/pypa/cibuildwheel/blob/main/examples/github-deploy.yml

# Build on every branch push, tag push, and pull request change:
#on: [push, pull_request]
# Alternatively, to publish when a (published) GitHub Release is created, use the following:
on:
release:
types:
- published

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- name: Setup GNU Fortran
uses: awvwgk/setup-fortran@v1

- name: Checkout
uses: actions/checkout@v4

- name: Build wheels
uses: pypa/[email protected]

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Build sdist
run: pipx run build --sdist

- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
#if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
# alternatively, to publish when a GitHub Release is created, use the following rule:
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- uses: actions/download-artifact@v3
with:
# unpacks default artifact into dist/
# if `name: artifact` is omitted, the action will create extra parent dir
name: artifact
path: dist

- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.pypi_password }}
# To test: repository_url: https://test.pypi.org/legacy/
22 changes: 15 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,29 @@ The core modules draw upon some utility packages, which are typically compiled c

## Installation

Installation with [Anaconda](https://www.anaconda.com) is the recommended approach because of the ability to create self-contained environments suitable for testing and analysis. WISDEM® requires [Anaconda 64-bit](https://www.anaconda.com/distribution/).
Installation with [Anaconda](https://www.anaconda.com) is the recommended approach because of the ability to create self-contained environments suitable for testing and analysis. WISDEM® requires [Anaconda 64-bit](https://www.anaconda.com/distribution/). However, the `conda` command has begun to show its age and we now recommend the one-for-one replacement with `mamba` via the [Miniforge distribution](https://github.com/conda-forge/miniforge/releases), which is much more lightweight and more easily solves for the WISDEM package dependencies.

### Installation as a "library"

To use WISDEM's modules as a library for incorporation into other scripts or tools, WISDEM is available via `mamba install wisdem` or `pip install wisdem`, assuming that you have already setup your python environment. Note that on Windows platforms, we suggest using `conda/mamba` exclusively.

### Installation for direct use

These instructions are for interaction with WISDEM directly, the use of its examples, and the direct inspection of its source code.

The installation instructions below use the environment name, "wisdem-env," but any name is acceptable. For those working behind company firewalls, you may have to change the conda authentication with `conda config --set ssl_verify no`. Proxy servers can also be set with `conda config --set proxy_servers.http http://id:pw@address:port` and `conda config --set proxy_servers.https https://id:pw@address:port`. To setup an environment based on a different Github branch of WISDEM, simply substitute the branch name for `master` in the setup line.

1. Setup and activate the Anaconda environment from a prompt (Anaconda3 Power Shell on Windows or Terminal.app on Mac)

conda config --add channels conda-forge
conda env create --name wisdem-env -f https://raw.githubusercontent.com/WISDEM/WISDEM/master/environment.yml python=3.10
conda activate wisdem-env
mamba config --add channels conda-forge
mamba env create --name wisdem-env -f https://raw.githubusercontent.com/WISDEM/WISDEM/master/environment.yml python=3.10
mamba activate wisdem-env

2. In order to directly use the examples in the repository and peek at the code when necessary, we recommend all users install WISDEM in *developer / editable* mode using the instructions here. If you really just want to use WISDEM as a library and lean on the documentation, you can always do `conda install wisdem` and be done. Note the differences between Windows and Mac/Linux build systems. For Linux, we recommend using the native compilers (for example, gcc and gfortran in the default GNU suite).

conda install -y petsc4py mpi4py # (Mac / Linux only)
conda install -y gfortran # (Mac only without Homebrew or Macports compilers)
conda install -y m2w64-toolchain libpython # (Windows only)
mamba install -y petsc4py mpi4py # (Mac / Linux only)
mamba install -y gfortran # (Mac only without Homebrew or Macports compilers)
mamba install -y m2w64-toolchain libpython # (Windows only)
git clone https://github.com/WISDEM/WISDEM.git
cd WISDEM
python setup.py develop # Currently more reliable than: pip install -e
Expand Down
43 changes: 43 additions & 0 deletions docs/docstrings/var_guide_to_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python
import sys
import numpy as np
import pandas as pd
import json

# these were spot checked, unclear if there's a better way to directly
# obtain this mapping
var_prefixes = {
'assembly': '*.', # scattered all over the place
'ccblade': 'rotorse.',
're': 'rotorse.',
'rp': 'rotorse.',
'rs': 'rotorse.',
'stall_check': 'rotorse.',
'wt_class': 'rotorse.',
}

# the variable guide in csv format is generated by get_omdao_vars.py
tab = pd.read_csv('variable_guide.csv')
if tab.iloc[-1]['Description'] == 'description':
# throw out footer
tab = tab.iloc[:-1]
tab = tab.set_index('Variable')
tab['Units'] = tab['Units'].replace(np.nan, '-')
tab['Description'] = tab['Description'].replace(np.nan,'None')

# convert to dict
varsdict = {}
for varn,info in tab.iterrows():
curlev = varsdict
varlevels = varn.split('.')
toplevel = varlevels[0]
for lev in varlevels[:-1]:
if lev not in curlev:
curlev[lev] = {}
curlev = curlev[lev]
curlev[varlevels[-1]] = info.to_dict() # Units, Description
curlev[varlevels[-1]]['Name'] = var_prefixes.get(toplevel,'') + varn

# save
with open('variable_guide.json','w') as f:
json.dump(varsdict, f, indent=2)
Loading

0 comments on commit a2313a6

Please sign in to comment.