Skip to content

Commit

Permalink
CI Testing (WISDEM#41)
Browse files Browse the repository at this point in the history
* CI initial commit

* rename to .yml

* Add environment yaml

* compile rosco

* checkout submodules properly

* Separate environment setup

* syntax fix

* run examples - initial commit

* typo fix

* Add pandas

* Install openfast

* temp-remove try for execute script

* Add run_examples

* name environment

* remove run_examples

* activate environment

* pwsh shell

* use bash, reorder wisdem install

* No shell

* typo

* Another typo

* remove names for setup

* remove environment name

* only build testing right now

* add back shell

* use powershell

* default shell

* Add run_examples back

* Add try statement

* assume linux for ROSCO shared lib

* Add macOS and windows to build testing

* install compilers on windows

* change to subprocess call

* Check for failure

* change exit code test

* fix file paths

* cleanup

* Add pull request template
  • Loading branch information
nikhar-abbas authored Mar 31, 2021
1 parent da6b56c commit 381ae28
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 20 deletions.
19 changes: 19 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Description and Purpose

## Type of change
What types of change is it?
_Select the appropriate type(s) that describe this PR_

- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (non-backwards-compatible fix or feature)
- [ ] Code style update (formatting, renaming)
- [ ] Refactoring (no functional changes, no API changes)
- [ ] Documentation update
- [ ] Maintenance update
- [ ] Other (please describe)

## Github issues addressed, if one exists

## Examples/Testing, if applicable

106 changes: 106 additions & 0 deletions .github/workflows/CI_rosco-toolbox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: CI_rosco-toolbox

# We run CI on push commits on all branches
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 }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
python-version: ["3.8"]
defaults:
run:
shell: bash -l {0}

steps:
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
submodules: recursive

- name: Setup environment
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
channels: conda-forge, general
auto-update-conda: true
python-version: 3.8
environment-file: environment.yml


# Install dependencies of ROSCO toolbox
- name: Add dependencies ubuntu specific
if: false == contains( matrix.os, 'windows')
run: |
conda install -y compilers
conda install -y wisdem
- name: Add dependencies windows specific
if: true == contains( matrix.os, 'windows')
run: |
conda install -y m2w64-toolchain libpython
conda install -y wisdem
# Install ROSCO toolbox
- name: Install ROSCO toolbox
run: |
python setup.py develop --compile-rosco
run_examples:
name: Run Examples
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: ["ubuntu-latest"] #, "macOS-latest"]
python-version: ["3.8"]
defaults:
run:
shell: bash -l {0}

steps:
- name: Checkout repository and submodules
uses: actions/checkout@v2
with:
submodules: recursive

- name: Setup environment
uses: conda-incubator/setup-miniconda@v2
with:
miniconda-version: "latest"
channels: conda-forge, general
auto-update-conda: true
python-version: 3.8
environment-file: environment.yml


# Install dependencies of ROSCO toolbox
- name: Add dependencies ubuntu specific
if: false == contains( matrix.os, 'windows')
run: |
conda install -y compilers
conda install -y wisdem
# Install ROSCO toolbox
- name: Install ROSCO toolbox
run: |
python setup.py develop --compile-rosco
# Install OpenFAST
- name: Install OpenFAST
run: |
conda install openfast
# Run examples
- name: Run examples
run: |
cd Examples
python run_examples.py
4 changes: 3 additions & 1 deletion Examples/example_09.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
wind_directory = os.path.join(this_dir,'../Test_Cases/Wind/')
turbsim_infile = '90m_12mps_twr.inp'

run_openfast(wind_directory, fastcall='turbsim', fastfile=turbsim_infile, chdir=False)
run_openfast(wind_directory, fastcall='turbsim',
fastfile=os.path.join(wind_directory, turbsim_infile), chdir=False)

print('test')
4 changes: 3 additions & 1 deletion Examples/run_examples.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import unittest
import sys
from time import time
import importlib

Expand Down Expand Up @@ -100,4 +101,5 @@ def suite():


if __name__ == "__main__":
unittest.TextTestRunner().run(suite())
result = unittest.TextTestRunner().run(suite())
sys.exit(not result.wasSuccessful())
23 changes: 8 additions & 15 deletions ROSCO_toolbox/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
from matplotlib import transforms
from itertools import takewhile, product
import struct
import subprocess
import ROSCO_toolbox

from ROSCO_toolbox.ofTools.util import spectral
# Some useful constants
now = datetime.datetime.now()
pi = np.pi
Expand Down Expand Up @@ -455,7 +455,7 @@ def DISCON_dict(turbine, controller, txt_filename=None):
return DISCON_dict


def run_openfast(fast_dir,fastcall='openfast',fastfile=None,chdir=False):
def run_openfast(fast_dir, fastcall='openfast', fastfile=None, chdir=True):
'''
Runs a openfast openfast simulation.
Expand Down Expand Up @@ -483,18 +483,11 @@ def run_openfast(fast_dir,fastcall='openfast',fastfile=None,chdir=False):
print('Using {} to run OpenFAST simulation'.format(fastfile))

if chdir: # Change cwd before calling OpenFAST -- note: This is an artifact of needing to call OpenFAST from the same directory as DISCON.IN
# save starting file path
original_path = os.getcwd()
# change path, run OpenFAST
os.chdir(fast_dir)
print('Running OpenFAST simulation for {} through the ROSCO toolbox...'.format(fastfile))
os.system('{} {}'.format(fastcall, os.path.join(fastfile)))
print('OpenFAST simulation complete. ')
# return to original path
os.chdir(original_path)
cwd = fast_dir
else:
# Run OpenFAST
print('Running OpenFAST simulation for {} through the ROSCO toolbox...'.format(fastfile))
os.system('{} {}'.format(fastcall, os.path.join(fast_dir,fastfile)))
print('OpenFAST simulation complete. ')
cwd = None

print('Running OpenFAST simulation for {} through the ROSCO toolbox...'.format(fastfile))
# os.system('{} {}'.format(fastcall, os.path.join(fastfile)))
subprocess.run([fastcall, os.path.join(fastfile)], check=True, cwd=cwd)
print('OpenFAST simulation complete.')
2 changes: 1 addition & 1 deletion Test_Cases/BAR_10/BAR_10_ServoDyn.dat
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ False CompNTMD - Compute nacelle tuned mass damper {true/fal
False CompTTMD - Compute tower tuned mass damper {true/false} (flag)
"b.dat" TTMDfile - Name of the file for tower tuned mass damper (quoted string) [unused when CompTTMD is false]
---------------------- BLADED INTERFACE ---------------------------------------- [used only with Bladed Interface]
"../../ROSCO/install/lib/libdiscon.dylib" DLL_FileName - Name/location of the dynamic library {.dll [Windows] or .so [Linux]} in the Bladed-DLL format (-) [used only with Bladed Interface]
"../../ROSCO/install/lib/libdiscon.so" DLL_FileName - Name/location of the dynamic library {.dll [Windows] or .so [Linux]} in the Bladed-DLL format (-) [used only with Bladed Interface]
"BAR_10_DISCON.IN" DLL_InFile - Name of input file sent to the DLL (-) [used only with Bladed Interface]
"DISCON" DLL_ProcName - Name of procedure in DLL to be called (-) [case sensitive; used only with DLL Interface]
"default" DLL_DT - Communication interval for dynamic library (s) (or "default") [used only with Bladed Interface]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ False CompNTMD - Compute nacelle tuned mass damper {true/fal
False CompTTMD - Compute tower tuned mass damper {true/false} (flag)
"unused" TTMDfile - Name of the file for tower tuned mass damper (quoted string) [unused when CompTTMD is false]
---------------------- BLADED INTERFACE ---------------------------------------- [used only with Bladed Interface]
"../../ROSCO/install/lib/libdiscon.dylib" DLL_FileName - Name/location of the dynamic library {.dll [Windows] or .so [Linux]} in the Bladed-DLL format (-) [used only with Bladed Interface]
"../../ROSCO/install/lib/libdiscon.so" DLL_FileName - Name/location of the dynamic library {.dll [Windows] or .so [Linux]} in the Bladed-DLL format (-) [used only with Bladed Interface]
"ServoData/DISCON-UMaineSemi.IN" DLL_InFile - Name of input file sent to the DLL (-) [used only with Bladed Interface]
"DISCON" DLL_ProcName - Name of procedure in DLL to be called (-) [case sensitive; used only with DLL Interface]
"default" DLL_DT - Communication interval for dynamic library (s) (or "default") [used only with Bladed Interface]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ False CompNTMD - Compute nacelle tuned mass damper {true/false} (fla
False CompTTMD - Compute tower tuned mass damper {true/false} (flag)
"../5MW_Baseline/NRELOffshrBsline5MW_ServoDyn_TMD.dat" TTMDfile - Name of the file for tower tuned mass damper (quoted string) [unused when CompTTMD is false]
---------------------- BLADED INTERFACE ---------------------------------------- [used only with Bladed Interface]
"../../ROSCO/install/lib/libdiscon.dylib" DLL_FileName - Name/location of the dynamic library {.dll [Windows] or .so [Linux]} in the Bladed-DLL format (-) [used only with Bladed Interface]
"../../ROSCO/install/lib/libdiscon.so" DLL_FileName - Name/location of the dynamic library {.dll [Windows] or .so [Linux]} in the Bladed-DLL format (-) [used only with Bladed Interface]
"DISCON.IN" DLL_InFile - Name of input file sent to the DLL (-) [used only with Bladed Interface]
"DISCON" DLL_ProcName - Name of procedure in DLL to be called (-) [case sensitive; used only with DLL Interface]
"default" DLL_DT - Communication interval for dynamic library (s) (or "default") [used only with Bladed Interface]
Expand Down
11 changes: 11 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
channels:
- conda-forge
- defaults

dependencies:
- matplotlib
- numpy
- pytest
- scipy
- pyYAML
- pandas

0 comments on commit 381ae28

Please sign in to comment.