Skip to content

Commit

Permalink
Merge pull request #218 from ImperialCollegeLondon/dev_docker
Browse files Browse the repository at this point in the history
SHARPy Docker now releases to GitHub Packages
  • Loading branch information
kccwing committed May 31, 2023
2 parents d5858d4 + 55d0286 commit 7aa139b
Show file tree
Hide file tree
Showing 14 changed files with 178 additions and 27 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/docker_build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Create and publish Docker image

on:
push:
branches:
- develop
- master
tags:
- 'v*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@v3.2.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
49 changes: 49 additions & 0 deletions .github/workflows/docker_build_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Test Docker image build

on:
pull_request:
branches:
- master
- develop
- 'rc*'
push:
paths:
- 'utils/*'
- 'Dockerfile'
- '.github/workflows/docker*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
test_image_build:
runs-on: ubuntu-latest
name: Test Docker image build
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build Docker image
uses: docker/build-push-action@v3.2.0
with:
context: .
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
23 changes: 23 additions & 0 deletions .github/workflows/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# SHARPy GitHub Workflows

There are 4 automated workflows for SHARPy's CI/CD.

## SHARPy Tests

The related to the SHARPy tests that run the `SHARPy Tests` job are:

* `sharpy_tests.yaml`: when Python or the submodules files are edited
* `sharpy_no_test_needed.yaml`: otherwise

This avoids running the full set of tests for changes in the documentation etc.
Since the merge to `develop` and `master` is protected by the tests passing, the
second workflow ensures a positive result for those PRs that did not change the
Python code, hence allowing the merge.

## Docker

Two nearly identical workflows, the only difference is that one pushes the Docker
image to the SHARPy packages. Therefore:

* `docker_build.yaml`: Builds the Docker image but does not push. Runs on changes to the `docker*` workflows, changes to the `utils/` directory (environments) and changes to the `Dockerfile`. Required test for PRs to merge to `develop` and `master`.
* `docker_build.yaml`: Builds and pushes the Docker image. Runs on pushes to `develop`, `master` and annotated tags.
2 changes: 1 addition & 1 deletion .github/workflows/sharpy_no_test_needed.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python package
name: SHARPy Tests

on:
pull_request:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sharpy_tests.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Python package
name: SHARPy Tests

on:
push:
paths:
- '*.py'
- 'lib/*'
- '.github/workflows/*'
- '.github/workflows/sharpy*'
pull_request:
branches:
- master
Expand Down
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ ENV BASH_ENV ~/.bashrc
SHELL ["/bin/bash", "-c"]
ENV PATH=${PATH}:/miniconda3/bin

# CENTOS 8 has reached end of life - Not yet an updated Docker base for CentOS stream
# Point to the CentOS 8 vault in order to download dependencies
RUN cd /etc/yum.repos.d/ && \
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && \
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* && \
cd /

# Development tools including compilers
RUN yum groupinstall "Development Tools" -y --nogpgcheck && \
yum install -y --nogpgcheck mesa-libGL libXt libXt-devel wget gcc-gfortran lapack vim tmux && \
Expand Down Expand Up @@ -34,11 +41,13 @@ RUN ln -s /sharpy_dir/utils/docker/* /root/

RUN cd sharpy_dir && \
conda activate sharpy_minimal && \
git submodule update --init --recursive && \
mkdir build && \
cd build && \
CXX=g++ FC=gfortran cmake .. && make install -j 2 && \
cd .. && \
pip install . && \
rm -rf build

ENTRYPOINT ["/bin/bash", "--init-file", "/root/bashrc"]

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ is:

Master
![Build Status](https://github.com/ImperialCollegeLondon/sharpy/actions/workflows/sharpy_tests.yaml/badge.svg)
![Docker Status](https://github.com/ImperialCollegeLondon/sharpy/actions/workflows/docker_build.yaml/badge.svg)

Develop
![Build Status](https://github.com/ImperialCollegeLondon/sharpy/actions/workflows/sharpy_tests.yaml/badge.svg?branch=develop)
44 changes: 29 additions & 15 deletions docs/source/content/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ you would like to install a develop build or modify the compilation settings of
cd sharpy
```

1. Ensure that the SHARPy environment is active in the session. Your terminal prompt line should begin with
2. Ensure that the SHARPy environment is active in the session. Your terminal prompt line should begin with
```bash
(sharpy) [usr@host] $
```
Expand All @@ -107,30 +107,35 @@ you would like to install a develop build or modify the compilation settings of
conda activate sharpy
```

1. Create a directory `build` that will be used during CMake's building process and `cd` into it:
3. Create a directory `build` that will be used during CMake's building process and `cd` into it:
```bash
mkdir build
cd build
```

2. Prepare UVLM and xbeam for compilation using `gfortran` and `g++` in their release builds running. If you'd like to
4. Prepare UVLM and xbeam for compilation using `gfortran` and `g++` in their release builds running. If you'd like to
change compilers see the Custom Installation.
```bash
cmake ..
```

3. Compile the libraries
5. Compile the libraries
```bash
make install -j 4
```
where the number after the `-j` flag will specify how many cores to use during installation.

4. Finally, leave the build directory and install SHARPy
6. Finally, leave the build directory and install SHARPy
```bash
cd ..
pip install .
```

7. You can check the version of SHARPy you are running with
```bash
sharpy --version
```

__You are ready to run SHARPy__. Continue reading the [Running SHARPy](#running-sharpy) section.

### Custom installation
Expand Down Expand Up @@ -218,16 +223,25 @@ If this works, you're good to go!

First, obtain the SHARPy docker container:
```
docker pull fonsocarre/sharpy:stable
docker pull ghcr.io/imperialcollegelondon/sharpy:master
```
You can obtain other versions as well, check those available in the [containers](https://github.com/ImperialCollegeLondon/sharpy/pkgs/container/sharpy) page.

This will donwload a Docker image of SHARPy to your machine, from where you can create and run Docker containers. To create and run a container from the downloaded image use:

Now you can run it:
```
docker run --name sharpy -it fonsocarre/sharpy:stable
docker run --name sharpy -it -p 8080:8080 ghcr.io/imperialcollegelondon/sharpy:master
```
You should see a welcome dialog such as:

A few details about the above command, although if in doubt please check the Docker documentation. The `--name` argument gives a name to the container. Note you can create multiple containers from a single image.

The `-it` is an important command as it runs the container in interactive mode with a terminal attached. Thus you can use it an navigate it. Otherwise the container will finish as soon as it is created.

The `-p 8080:8080` argument connects the container to your machine through port `8080` (it could be any other) which may be useful for some applications. For instance, running SHARPy as hardware-in-the-loop through UDP.

Once you run it, you should see a welcome dialog such as:
```
>>>> docker run -it fonsocarre/sharpy:stable
>>>> docker run --name sharpy -it -p 8080:8080 ghcr.io/imperialcollegelondon/sharpy:master
SHARPy added to PATH from the directory: /sharpy_dir/bin
=======================================================================
Welcome to the Docker image of SHARPy
Expand All @@ -239,6 +253,11 @@ SHARPy>
```
You are now good to go.

You can check the version of SHARPy you are running with
```
sharpy --version
```

It is important to note that a docker container runs as an independent
operating system with no access to your hard drive. If you want to copy your own
files, run the container and from another terminal run:
Expand All @@ -254,11 +273,6 @@ cd sharpy_dir
python -m unittest
```

We make available two different releases: `stable` and `experimental`. The former is the latest SHARPy
release. The latter is our latest development work which will include new features but with higher chances
of encountering some bugs along the way. To obtain the experimental build, follow the instructions
above replacing the `stable` tag for `experimental`.

**Enjoy!**


Expand Down
12 changes: 9 additions & 3 deletions docs/source/content/publications.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ Here we present a list of past papers which have used SHARPy for research purpos

## 2022

* Goizueta, N., Wynn, A., Palacios, R., Drachinsky, A., Raveh, D. E. (2022). Flutter Predictions for Very Flexible Wing Wind Tunnel Test. Journal of Aircraft. Article in Advance. [https://doi.org/10.2514/1.C036710](https://doi.org/10.2514/1.C036710)
* Goizueta, N. (2022). Parametric reduced-order aeroelastic modelling for analysis, dynamic system interpolation and control of flexible aircraft. PhD Thesis. [http://doi.org/10.25560/100137](http://doi.org/10.25560/100137)

* Muñoz-Simón A, Wynn A, Palacios R (2022). Some modelling improvements for prediction of wind turbine rotor loads in turbulent wind. Wind Energy: 25(2), pp. 333-353. [https://doi.org/10.1002/we.2675](https://doi.org/10.1002/we.2675)
* Goizueta, N., Wynn, A., & Palacios, R. (2022). Adaptive sampling for interpolation of reduced-order aeroelastic dynamical systems. AIAA Journal. Article in Advance. [https://doi.org/10.2514/1.J062050](https://doi.org/10.2514/1.J062050)

* Goizueta, N., Wynn, A., Palacios, R. (2022). Fast flutter evaluation of very flexible wing using interpolation on an optimal training dataset. AIAA SciTech Forum. [https://doi.org/10.2514/6.2022-1345](https://doi.org/10.2514/6.2022-1345)
* Muñoz Simón, A. (2022). Vortex-lattice-based nonlinear aeroservoelastic modelling and analysis of large floating wind turbines. PhD Thesis. [https://doi.org/10.25560/96986](https://doi.org/10.25560/96986)

* Goizueta, N., Wynn, A., Palacios, R., Drachinsky, A., & Raveh, D. E. (2022). Flutter Predictions for Very Flexible Wing Wind Tunnel Test. Journal of Aircraft: 59(4), pp. 1082-1097. [https://doi.org/10.2514/1.C036710](https://doi.org/10.2514/1.C036710)

* Düssler, S., Goizueta, N., Muñoz-Simón, A., & Palacios, R. (2022). Modelling and Numerical Enhancements on a UVLM for Nonlinear Aeroelastic Simulation. AIAA SciTech Forum. [https://doi.org/10.2514/6.2022-2455](https://doi.org/10.2514/6.2022-2455)

* Cea, A., Palacios, R. (2022). Parametric Reduced Order Models for Aeroelastic Design of Very Flexible Aircraft. AIAA SciTech Forum. [https://doi.org/10.2514/6.2022-0727](https://doi.org/10.2514/6.2022-0727)

* Wynn, A., Artola, M., Palacios, R. (2022). Nonlinear optimal control for gust load alleviation with a physics-constrained data-driven internal model. AIAA SciTech Forum. [https://doi.org/10.2514/6.2022-0442](https://doi.org/10.2514/6.2022-0442)

* Goizueta, N., Wynn, A., Palacios, R. (2022). Fast flutter evaluation of very flexible wing using interpolation on an optimal training dataset. In AIAA SciTech Forum, AIAA Paper 2022-1345. [https://doi.org/10.2514/6.2022-1345](https://doi.org/10.2514/6.2022-1345)

## 2021

* Artola, M., Goizueta, N., Wynn, A., & Palacios, R. (2021). Aeroelastic Control and Estimation with a Minimal
Expand All @@ -34,6 +38,8 @@ models. In AIAA SciTech Forum (pp. 1–25). [https://doi.org/10.2514/6.2021-1798

## 2020

* del Carre, A. (2020). Aeroelasticity of very flexible aircraft at low altitudes. PhD Thesis. [https://doi.org/10.25560/88269](https://doi.org/10.25560/88269)

* Muñoz-Simón, A., Palacios, R., & Wynn, A. (2020). Benchmarking different fidelities in wind turbine aerodynamics
under yaw. Journal of Physics: Conference Series, 1618, 42017.
[https://doi.org/10.1088/1742-6596/1618/4/042017](https://doi.org/10.1088/1742-6596/1618/4/042017)
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import re
import os

this_directory = os.path.abspath(os.path.dirname(__file__))
__version__ = re.findall(
r"""__version__ = ["']+([0-9\.]*)["']+""",
open("sharpy/__init__.py").read(),
open(os.path.join(this_directory, "sharpy/version.py")).read(),
)[0]

this_directory = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(this_directory, "README.md"), encoding="utf-8") as f:
long_description = f.read()

Expand Down
2 changes: 1 addition & 1 deletion sharpy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "2.0"
from .version import __version__
5 changes: 4 additions & 1 deletion sharpy/sharpy_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import sys
import dill as pickle
import sharpy.utils.cout_utils as cout
from .version import __version__


def main(args=None, sharpy_input_dict=None):
Expand Down Expand Up @@ -56,12 +57,14 @@ def main(args=None, sharpy_input_dict=None):
if sharpy_input_dict is None:
parser = argparse.ArgumentParser(prog='SHARPy', description=
"""This is the executable for Simulation of High Aspect Ratio Planes.\n
Imperial College London 2021""")
Imperial College London 2022""")
parser.add_argument('input_filename', help='path to the *.sharpy input file', type=str, default='')
parser.add_argument('-r', '--restart', help='restart the solution with a given snapshot', type=str,
default=None)
parser.add_argument('-d', '--docs', help='generates the solver documentation in the specified location. '
'Code does not execute if running this flag', action='store_true')
parser.add_argument('-v', '--version', action='version',
version='Running %(prog)s version {version}'.format(version=__version__))
if args is not None:
args = parser.parse_args(args[1:])
else:
Expand Down
2 changes: 2 additions & 0 deletions sharpy/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# version stored here to don't load dependencies by storing it in __init__.py
__version__ = '2.0'
1 change: 0 additions & 1 deletion utils/docker/bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ unset __conda_setup
# <<< conda initialize <<<

conda activate sharpy_minimal
source /sharpy_dir/bin/sharpy_vars.sh

# custom prompt
PS1="SHARPy> "
Expand Down

0 comments on commit 7aa139b

Please sign in to comment.