Skip to content

Commit

Permalink
simplify and modernize the setup and test experience
Browse files Browse the repository at this point in the history
  • Loading branch information
gbarter committed Jan 5, 2024
1 parent 92e2ac5 commit e58d3f1
Show file tree
Hide file tree
Showing 10 changed files with 304 additions and 223 deletions.
170 changes: 104 additions & 66 deletions .github/workflows/CI_rosco-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,80 +3,118 @@ name: CI_rosco-compile
# We run CI on push commits on all branches
on: [push, pull_request]

# Specify FORTRAN compiler, used to be "gfortran-10"
env:
FORTRAN_COMPILER: gfortran

# 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", "windows-latest" , "macOS-latest"]
python-version: ["3.9"]
build_pip:
name: Pip Build (${{ matrix.os }}) - ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -l {0}

strategy:
fail-fast: false #true
matrix:
os: ["ubuntu-latest", "macOS-latest", "windows-latest"]
python-version: ["3.9", "3.10", "3.11", "3.12"]

steps:
- name: Checkout repository
uses: actions/checkout@v3
steps:
- name: Setup GNU Fortran
# if: false == contains( matrix.os, 'windows')
uses: awvwgk/setup-fortran@v1 #modflowpy/install-intelfortran-action@v1 #

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

- name: Install conda/mamba
uses: conda-incubator/setup-miniconda@v2
# https://github.com/marketplace/actions/setup-miniconda
with:
# 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
activate-environment: test
auto-activate-base: false
miniforge-variant: Mambaforge
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
id: cp
with:
python-version: ${{ matrix.python-version }}
update-environment: true

# Install ROSCO toolbox
- name: Install ROSCO toolbox
shell: bash -l {0}
run: |
python setup.py install
#- name: Setup tmate session
# if: contains( matrix.os, 'windows')
# uses: mxschmitt/action-tmate@v3

- name: Pip Install ROSCO
run: |
'${{ steps.cp.outputs.python-path }}' -m pip install -vv -e .
# Re-generate registry
- name: Generate Registry
shell: bash -l {0}
run: python rosco/controller/rosco_registry/write_registry.py

- name: Add dependencies windows
if: true == contains( matrix.os, 'windows')
run: |
conda install -y m2w64-toolchain
# Re-generate registry
- name: Generate Registry
run: |
'${{ steps.cp.outputs.python-path }}' ROSCO/controller/rosco_registry/write_registry.py
- name: Test run
run: |
cd Examples
'${{ steps.cp.outputs.python-path }}' 01_turbine_model.py
- name: Add dependencies windows
if: true == contains( matrix.os, 'mac')
shell: bash -l {0}
run: |
conda install -y gfortran
build_conda:
name: Conda Build (${{ matrix.os }}) - ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -el {0}

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

- name: Setup Workspace
run: |
cmake -E make_directory ${{runner.workspace}}/ROSCO/rosco/controller/build
steps:
- name: checkout repository
uses: actions/checkout@v4

- name: Configure and Build - unix
if: false == contains( matrix.os, 'windows')
shell: bash -l {0}
working-directory: "${{runner.workspace}}/ROSCO/rosco/controller/build"
run: |
cmake \
-DCMAKE_INSTALL_PREFIX:PATH=${{runner.workspace}}/ROSCO/rosco/controller/install \
-DCMAKE_Fortran_COMPILER:STRING=${{env.FORTRAN_COMPILER}} \
..
cmake --build . --target install
- uses: conda-incubator/setup-miniconda@v2
# https://github.com/marketplace/actions/setup-miniconda
with:
#mamba-version: "*"
miniforge-version: "latest"
auto-update-conda: true
python-version: ${{ matrix.python-version }}
environment-file: environment.yml
activate-environment: test
auto-activate-base: false

- name: Configure and Build - windows
if: true == contains( matrix.os, 'windows')
#shell: bash #-l {0}
working-directory: "${{runner.workspace}}/ROSCO/rosco/controller/build"
run: |
cmake -G "MinGW Makefiles" -DCMAKE_INSTALL_PREFIX="${{runner.workspace}}/ROSCO/rosco/controller/build" ..
cmake --build . --target install
- name: Add dependencies windows specific
if: contains( matrix.os, 'windows')
run: |
conda install -y m2w64-toolchain libpython
- name: Add dependencies mac specific
if: contains( matrix.os, 'mac')
run: |
conda install -y compilers
gfortran --version
# Install
- name: Debug
run: |
conda list
printenv
#- name: Setup tmate session
# uses: mxschmitt/action-tmate@v3
# with:
# detached: true
# if: contains( matrix.os, 'windows')

# Install
- name: Conda Install ROSCO
run: |
python -m pip install -vv -e .
# Re-generate registry
- name: Generate Registry
run: |
python ROSCO/controller/rosco_registry/write_registry.py
- name: Test run
run: |
cd Examples
python 01_turbine_model.py
4 changes: 3 additions & 1 deletion Examples/test_examples.py → ROSCO/test/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
]

def execute_script(fscript):
examples_dir = os.path.dirname(os.path.realpath(__file__))
this_dir = os.path.dirname(os.path.abspath(__file__))
rosco_dir = os.path.dirname( os.path.dirname(this_dir) )
examples_dir = os.path.join(rosco_dir,'Examples')
test_case_dir = os.path.join(examples_dir,'Test_Cases')

# Go to location due to relative path use for airfoil files
Expand Down
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
- pandas
- wisdem
- cmake
- pyparsing==2.4.7
- pyparsing
- control
- pyzmq
- mpi4py
Expand Down
139 changes: 139 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
[build-system]
requires = ["setuptools", "cmake", "numpy", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "ROSCO"
version = "2.9.0"
description = "A reference open source controller toolset for wind turbine applications."
readme = "README.md"
requires-python = ">=3.9"
license = {text = "Apache-2.0"}
keywords = ["wind", "turbine", "control", "", ""]
authors = [
{name = "National Wind Technology Center, NREL", email = "[email protected]" }
]
maintainers = [
{name = "Daniel Zalkind", email = "[email protected]" }
]
classifiers = [ # Optional
# How mature is this project? Common values are
# 3 - Alpha
# 4 - Beta
# 5 - Production/Stable
"Development Status :: 4 - Beta",

# Indicate who your project is intended for
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering",

"License :: OSI Approved :: Apache Software License",

# Specify the Python versions you support here. In particular, ensure
# that you indicate you support Python 3. These classifiers are *not*
# checked by "pip install". See instead "python_requires" below.
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Fortran",
]

dependencies = [
"control",
"numpy",
"matplotlib",
"mpi4py",
"scipy",
"pandas",
"pyparsing",
"pyYAML",
"pyzmq",
"treon",
"wisdem",
]

# List additional groups of dependencies here (e.g. development
# dependencies). Users will be able to install these using the "extras"
# syntax, for example:
#
# $ pip install sampleproject[dev]
#
# Similar to `dependencies` above, these must be valid existing
# projects.
[project.optional-dependencies] # Optional
dev = ["cmake"]
test = ["pytest"]

# List URLs that are relevant to your project
#
# This field corresponds to the "Project-URL" and "Home-Page" metadata fields:
# https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use
# https://packaging.python.org/specifications/core-metadata/#home-page-optional
#
# Examples listed include a pattern for specifying where the package tracks
# issues, where the source is hosted, where to say thanks to the package
# maintainers, and where to support the project financially. The key is
# what's used to render the link text on PyPI.
[project.urls] # Optional
"Homepage" = "https://github.com/NREL/ROSCO"
"Documentation" = "https://rosco.readthedocs.io"

# This is configuration specific to the `setuptools` build backend.
# If you are using a different build backend, you will need to change this.
[tool.setuptools]
zip-safe = false
include-package-data = true

#[tool.setuptools.packages]
#find = {}

[tool.setuptools.packages.find]
#where = ["ROSCO"]
exclude = ["Matlab_Toolbox"]
namespaces = true

[tool.setuptools.package-data]
# If there are data files included in your packages that need to be
# installed, specify them here.
"*" = ["*.yaml", "*.xlsx", "*.txt", "*.so", "*.lib", "*.pyd", "*.pdb", "*.dylib", "*.dll", "*.exe"]

[tool.black]
line-length = 120
target-version = ['py311']
include = '\.pyi?$'
exclude = '''
/(
\.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''

[tool.isort]
# https://github.com/PyCQA/isort
multi_line_output = "3"
include_trailing_comma = true
force_grid_wrap = false
use_parentheses = true
line_length = "120"
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"]
known_first_party = ["wisdem"]
length_sort = "1"
profile = "black"
skip_glob = ['__init__.py']
atomic = true
#lines_after_imports = 2
#lines_between_types = 1
#src_paths=isort,test

[tool.cibuildwheel]
skip = ["cp36-*", "cp37-*", "cp38-*", "*-win32", "*arm64", "pp*"]
build-frontend = "build"
6 changes: 3 additions & 3 deletions rosco/controller/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.6)
project(ROSCO VERSION 2.8.0 LANGUAGES Fortran C)
project(ROSCO VERSION 2.9.0 LANGUAGES Fortran C)

set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}/ftnmods")

Expand Down Expand Up @@ -114,5 +114,5 @@ set(linuxDefault ${CMAKE_INSTALL_PREFIX} STREQUAL "/usr/local")
set(windowsDefault ${CMAKE_INSTALL_PREFIX} STREQUAL "C:\\Program Files (x86)")
if(${linuxDefault} OR ${windowsDefault})
message("TRUE")
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/install")
endif()
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/../../")
endif()
Loading

0 comments on commit e58d3f1

Please sign in to comment.