-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release/0.0.0: Make deployable See merge request windenergie-hsr/aerosense/digital-twin/fsi-twins/panel-codes-twine!2
- Loading branch information
Showing
30 changed files
with
1,051 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
venv/ | ||
.git | ||
*.egg-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
default: | ||
image: python:3.6 | ||
|
||
build_and_test: | ||
variables: | ||
TEST_PROJECT_NAME: $TEST_PROJECT_NAME | ||
GOOGLE_APPLICATION_CREDENTIALS: $GOOGLE_APPLICATION_CREDENTIALS | ||
cache: | ||
paths: | ||
- requirements-dev.txt | ||
when: 'on_success' | ||
key: 'build_and_test' | ||
script: | ||
- apt-get update -y && apt-get install -y --fix-missing build-essential gfortran | ||
- python3 -m venv test-venv | ||
- bash test-venv/bin/activate | ||
- git clone https://github.com/daniel-de-vries/xfoil-python.git && pip install ./xfoil-python | ||
- pip install -r requirements-dev.txt | ||
- coverage run -m unittest | ||
- coverage report | ||
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# xfoil-python only seems to work on python 3.6. | ||
FROM python:3.6-slim-buster | ||
|
||
# Allow statements and log messages to immediately appear in the Knative logs on Google Cloud. | ||
ENV PYTHONUNBUFFERED True | ||
|
||
ENV PROJECT_ROOT=/app | ||
WORKDIR $PROJECT_ROOT | ||
|
||
RUN apt-get update -y && apt-get install -y --fix-missing build-essential gfortran git && rm -rf /var/lib/apt/lists/* | ||
|
||
# xfoil-python has to be installed locally from a clone (and only seems to work on python 3.6). | ||
RUN git clone https://github.com/daniel-de-vries/xfoil-python.git && pip install ./xfoil-python | ||
|
||
COPY requirements-dev.txt . | ||
COPY setup.py . | ||
COPY . . | ||
|
||
RUN pip install --upgrade pip && pip install -r requirements-dev.txt | ||
|
||
EXPOSE $PORT | ||
|
||
ARG _SERVICE_ID | ||
ENV SERVICE_ID=$_SERVICE_ID | ||
|
||
ARG _GUNICORN_WORKERS=1 | ||
ENV _GUNICORN_WORKERS=$_GUNICORN_WORKERS | ||
|
||
ARG _GUNICORN_THREADS=8 | ||
ENV _GUNICORN_THREADS=$_GUNICORN_THREADS | ||
|
||
# Timeout is set to 0 to disable the timeouts of the workers to allow Cloud Run to handle instance scaling. | ||
CMD exec gunicorn --bind :$PORT --workers $_GUNICORN_WORKERS --threads $_GUNICORN_THREADS --timeout 0 octue.cloud.deployment.google.cloud_run:app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,107 +1,21 @@ | ||
# panel-code-twine-python | ||
A simple twine that runs panel codes. This repository is mirrored to Google Cloud Source Repositories. | ||
|
||
## Creating a twine | ||
|
||
First, think about: | ||
- what data you want to flow into and out of the app | ||
- what kinds of datasets (groups of files) the app might need to access | ||
- what other applicaitons / twins ('children') you need to use | ||
- what credentials you might need (e.g. if you're accessing a database or a third party API | ||
|
||
The **twine** file secifies all these things and more. First, place an empty `twine.json` file in the root directory of the app. | ||
|
||
See [https://twined.readthedocs.io](https://twined.readthedocs.io) for everything there is to know about how to define a twine. If you log in to [octue.com](https://www.octue.com/login) you'll find tools to help you build the twine. | ||
### Building documents manually | ||
|
||
*Note: this example app is not up to date with the current version of twined! Follow or comment on [this issue](https://github.com/octue/octue-app-python/issues/1).* | ||
**If you did need to build the documentation** | ||
|
||
|
||
## First steps in development | ||
Install `doxgen`. On a mac, that's `brew install doxygen`; other systems may differ. | ||
|
||
If you've not developed python applications before, we strongly recommend the following practices: | ||
|
||
- Use an Integrated Development Environment (IDE) to help you. We recommend [Pycharm, by Jetbrains](https://www.jetbrains.com/pycharm/) because it's cross-platform (i.e. for Windows, Mac and Linux), very friendly, and there's a free "Community Edition" which should have all the features you need for now. | ||
- Ensure Python 3.5 or greater is installed. (Mac users: use [pyenv](https://github.com/pyenv/pyenv), windows users could try [pyenv-win](https://github.com/pyenv-win/pyenv-win)) | ||
- [Configure a Virtual Environment](https://www.jetbrains.com/help/pycharm/creating-virtual-environment.html) to ensure you always have a consistent python environment and packages installed. | ||
|
||
Once you've set yourself up with Python 3.7+, an IDE and an activated virtual environment, you're ready to go: | ||
|
||
- PyCharm will usually do this for you, but if not, install the project dependencies (see `requirements.txt`). | ||
- Set up a directory containing your input data. How to do this is covered below, in 'Data Directories'. | ||
|
||
### Running your app (whilst developing) | ||
|
||
`>> python app.py`. Simple as that. You can specify a | ||
|
||
|
||
### Connecting to the octue platform | ||
|
||
1. Log in to [octue.com](www.octue.com), click `applications > create` in the sidebar, and follow the wizard. Simples! | ||
|
||
|
||
## Data directories | ||
|
||
Octue uses a strict folder structure, to help separate input, output, and temporary data. The structure looks like this: | ||
Install sphinx and other requirements for building the docs: | ||
``` | ||
my_data_folder | ||
| | ||
|- input | ||
| | | ||
| |- config.json | ||
| |- manifest.json | ||
| |- <dataset_xx> | ||
| | | | ||
| | |- <file_xxx> | ||
| | |- <file_xxy> | ||
| | |- <file_xxz> | ||
| | |- ... | ||
| | | ||
| |- <dataset_xy> | ||
| | | | ||
| | |- <file_xyx> | ||
| | |- <file_xyy> | ||
| | |- <file_xyz> | ||
| | |- ... | ||
| | | ||
| |- ... | ||
| | ||
|- logs | ||
| | | ||
| |- ... | ||
| | ||
|- tmp | ||
| | | ||
| |- ... | ||
| | ||
|- output | ||
| | | ||
| |- ... | ||
pip install -r docs/requirements.txt | ||
``` | ||
|
||
- Folder **`input`** contains any input datasets (groups of files). Within each dataset - you can simply dump a load of files created by an instrument or supplied by a third party here. These files should never be altered by the application. | ||
- Folder **`logs`** will contain log files produced while running the application. You shouldn't need to use these, as all output will be shown either in your terminal or on octue online. | ||
- Folder **`tmp`** you can write any temporary files (e.g. large cached calculations that are reused but don't form part of the results) here. | ||
- Folder **`output`** all output files should be saved to this directory. Any output files (like figures) produced by octue are saved here too. | ||
|
||
- File **``input/manifest.json``** contains a list of all the files in the input directory, with any tags that are applied (see 'generating the manifest file', below).. | ||
- File **``input/config.json``** contains a list of options and configuration parameters to use when running the application (see 'generating the config file', below). | ||
|
||
|
||
### Generating the config and manifest files | ||
|
||
When a user (you, or someone else) launches an application on octue, they fill in a form (which is generated from the twine). That creates a | ||
`config.json` file automatically. You can download this for local development. | ||
|
||
Connecting datasets to the application creates the `manifest.json`, which you can download too. | ||
|
||
But, if you're just testing your own application out, its helpful to generate these files yourself. | ||
|
||
The `octue_app_python` repository contains a `schema.json` for the example application. | ||
Go to [the octue schema playground](https://www.octue.com/schema/playground), and paste the entire contents of | ||
`schema.json` into the top left box. | ||
|
||
Fill in the form (it's already populated with defaults) and you'll see your **config** change as you do, in the bottom | ||
right box. This is what gets pasted into `config.json` (see `octue_app_python/example_data/config.json`). | ||
|
||
You can play around with schema in that playground (if you're having trouble, use the excellent | ||
[JSON Editor Online](https://jsoneditoronline.org/) to help debug them if you run into trouble. | ||
Run the build process: | ||
``` | ||
sphinx-build -b html docs/source docs/build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
steps: | ||
- name: gcr.io/cloud-builders/docker | ||
args: | ||
- build | ||
- '--no-cache' | ||
- '-t' | ||
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA' | ||
- --build-arg | ||
- _SERVICE_ID=$_SERVICE_ID | ||
- . | ||
- '-f' | ||
- Dockerfile | ||
id: Build | ||
- name: gcr.io/cloud-builders/docker | ||
args: | ||
- push | ||
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA' | ||
id: Push | ||
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:slim' | ||
args: | ||
- run | ||
- services | ||
- update | ||
- $_SERVICE_NAME | ||
- '--platform=managed' | ||
- '--image=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA' | ||
- >- | ||
--labels=managed-by=gcp-cloud-build-deploy-cloud-run,commit-sha=$COMMIT_SHA,gcb-build-id=$BUILD_ID,gcb-trigger-id=$_TRIGGER_ID,$_LABELS | ||
- '--region=$_DEPLOY_REGION' | ||
- '--quiet' | ||
id: Deploy | ||
entrypoint: gcloud | ||
images: | ||
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA' | ||
options: | ||
substitutionOption: ALLOW_LOOSE | ||
substitutions: | ||
_GCR_HOSTNAME: eu.gcr.io | ||
_PLATFORM: managed | ||
_SERVICE_NAME: panel-codes-twine | ||
_LABELS: gcb-trigger-id=c11b2517-2b8b-435b-9a30-8213e322851b | ||
_TRIGGER_ID: c11b2517-2b8b-435b-9a30-8213e322851b | ||
_DEPLOY_REGION: europe-north1 | ||
tags: | ||
- gcp-cloud-build-deploy-cloud-run | ||
- gcp-cloud-build-deploy-cloud-run-managed | ||
- panel-codes-twine |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{ | ||
"airfoil_name": "naca-0012", | ||
"alpha_range": [0, 6, 1], | ||
"inflow_speed": 1, | ||
"kinematic_viscosity": 1e-5, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"app_dir": ".", | ||
"twine": "twine.json", | ||
"configuration_values": { | ||
"analysis_program": "xfoil", | ||
"max_iterations": 20 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
doctrees | ||
html | ||
source/doxyoutput* | ||
source/library_api* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Required by the python script for building documentation | ||
Sphinx>=2,<3 | ||
sphinx-rtd-theme==0.5.0 | ||
sphinx-tabs==1.2.1 | ||
octue==0.1.12 | ||
pyserial==3.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.. _api: | ||
|
||
=== | ||
API | ||
=== | ||
|
||
|
||
.. _api_xfoil: | ||
|
||
X-Foil Module | ||
============= | ||
|
||
.. automodule:: xfoil_module.routines | ||
:members: |
Oops, something went wrong.