Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generic_bird optional component #41

Merged
merged 8 commits into from
Apr 15, 2020
5 changes: 5 additions & 0 deletions birdhouse/common.env
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# Jupyter single-user server image
export DOCKER_NOTEBOOK_IMAGE="pavics/workflow-tests:200312"

export FINCH_IMAGE="birdhouse/finch:version-0.5.2"
export GENERIC_BIRD_IMAGE="$FINCH_IMAGE"
export GENERIC_BIRD_PORT="8010"
export GENERIC_BIRD_NAME="generic_bird"

# Folder on the host to persist Jupyter user data (noteboooks, HOME settings)
export JUPYTERHUB_USER_DATA_DIR="/data/jupyterhub_user_data"

Expand Down
2 changes: 1 addition & 1 deletion birdhouse/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ services:
restart: always

finch:
image: birdhouse/finch:version-0.5.2
image: ${FINCH_IMAGE}
container_name: finch
environment:
HOSTNAME: $HOSTNAME
Expand Down
30 changes: 30 additions & 0 deletions birdhouse/optional-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,33 @@ server.

No Twitcher/Magpie access control, this Test Thredds is directly behind the
Nginx proxy.


## A generic bird WPS service

Can be used to quickly deploy any birds temporarily without changing code.
Good to preview new birds or test alternative configuration of existing birds.

How to enable in `env.local` (a copy from
[`env.local.example`](../env.local.example)):

* Add `./optional-components/generic_bird` to `EXTRA_CONF_DIRS`.

* Optionally set `GENERIC_BIRD_IMAGE`, `GENERIC_BIRD_PORT`, `GENERIC_BIRD_NAME` in `env.local`
for further customizations. Default values are in [`common.env`](../common.env).

The WPS service will be available at `http://PAVICS_FQDN:GENERIC_BIRD_PORT/wps`
or `https://PAVICS_FQDN_PUBLIC/TWITCHER_PROTECTED_PATH/GENERIC_BIRD_NAME` where
`PAVICS_FQDN`, `PAVICS_FQDN_PUBLIC` and `TWITCHER_PROTECTED_PATH` are defined
in your `env.local`.

Use same docker image as regular Finch by default but can be customized.

Use a separate Postgres DB for this optional component to be completely
self-contained and to allow experimenting with different versions of Postgres
DB.

Magpie will be automatically configured to give complete public anonymous
access for this WPS service.

Canarie monitoring will also be automatically configured for this WPS service.
4 changes: 4 additions & 0 deletions birdhouse/optional-components/generic_bird/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
wps.cfg
generic_bird-magpie-permission.cfg
generic_bird-magpie-provider.cfg
generic_bird_canarie_api_monitoring.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: '2.1'
services:
generic_bird:
image: ${GENERIC_BIRD_IMAGE}
container_name: generic_bird
environment:
PYWPS_CFG: /wps.cfg
ports:
- "${GENERIC_BIRD_PORT}:${GENERIC_BIRD_INTERNAL_PORT:-5000}"
volumes:
- ./optional-components/generic_bird/wps.cfg:/wps.cfg:ro
- wps_outputs:/data/wpsoutputs
- /tmp
links:
- postgres_generic_bird
restart: always

postgres_generic_bird:
image: ${GENERIC_BIRD_POSTGRES_IMAGE:-postgres:10.12}
container_name: postgres_generic_bird
volumes:
- postgres_generic_bird:/var/lib/postgresql/data/pgdata
- ./optional-components/generic_bird/postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d
environment:
PGDATA: /var/lib/postgresql/data/pgdata
env_file:
- ./config/postgres/credentials.env
restart: always

magpie:
volumes:
- ./optional-components/generic_bird/generic_bird-magpie-permission.cfg:/opt/local/src/magpie/config/permissions/generic_bird-magpie-permission.cfg:ro
- ./optional-components/generic_bird/generic_bird-magpie-provider.cfg:/opt/local/src/magpie/config/providers/generic_bird-magpie-provider.cfg:ro

proxy:
volumes:
- ./optional-components/generic_bird/generic_bird_canarie_api_monitoring.py:${CANARIE_MONITORING_EXTRA_CONF_DIR}/generic_bird_canarie_api_monitoring.py:ro

volumes:
postgres_generic_bird: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
permissions:
- service: ${GENERIC_BIRD_NAME}
permission: getcapabilities
group: anonymous
action: create

- service: ${GENERIC_BIRD_NAME}
permission: describeprocess
group: anonymous
action: create

- service: ${GENERIC_BIRD_NAME}
permission: execute
group: anonymous
action: create
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
providers:
${GENERIC_BIRD_NAME}:
url: http://${PAVICS_FQDN}:${GENERIC_BIRD_PORT}/wps
title: ${GENERIC_BIRD_NAME}
public: true
c4i: false
type: wps
sync_type: wps
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
SERVICES['node']['monitoring'].update({
'${GENERIC_BIRD_NAME}-public': {
'request': {
'url': 'https://${PAVICS_FQDN_PUBLIC}/${TWITCHER_PROTECTED_PATH}/${GENERIC_BIRD_NAME}?service=WPS&version=1.0.0&request=GetCapabilities'
},
},
'${GENERIC_BIRD_NAME}': {
'request': {
'url': 'http://${PAVICS_FQDN}:${GENERIC_BIRD_PORT}/wps?service=WPS&version=1.0.0&request=GetCapabilities'
}
},
})

# vi: tabstop=8 expandtab shiftwidth=4 softtabstop=4 syntax=python
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
credentials.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POSTGRES_USER=${POSTGRES_PAVICS_USERNAME}
POSTGRES_PASSWORD=${POSTGRES_PAVICS_PASSWORD}
POSTGRES_DB=pavics
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE DATABASE generic_bird;
9 changes: 9 additions & 0 deletions birdhouse/optional-components/generic_bird/wps.cfg.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[server]
outputurl = https://${PAVICS_FQDN_PUBLIC}/wpsoutputs
outputpath = /data/wpsoutputs

[logging]
level = INFO
database=postgresql://${POSTGRES_PAVICS_USERNAME}:${POSTGRES_PAVICS_PASSWORD}@postgres_generic_bird/generic_bird

${EXTRA_PYWPS_CONFIG}
2 changes: 2 additions & 0 deletions birdhouse/pavics-compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ OPTIONAL_VARS='
$AUTODEPLOY_PLATFORM_FREQUENCY
$AUTODEPLOY_NOTEBOOK_FREQUENCY
$AUTODEPLOY_EXTRA_SCHEDULER_JOBS
$GENERIC_BIRD_PORT
$GENERIC_BIRD_NAME
'

# we switch to the real directory of the script, so it still works when used from $PATH
Expand Down
8 changes: 6 additions & 2 deletions birdhouse/scripts/clear-running-wps-jobs-in-db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ else
shift
fi

if [ -z "$POSTGRES_CONTAINER_NAME" ]; then
POSTGRES_CONTAINER_NAME=postgres
fi

set -x
docker exec postgres psql -U $POSTGRES_USER $DB_NAME -c "select * from pywps_requests where percent_done > -1 and percent_done < 100.0;"
docker exec $POSTGRES_CONTAINER_NAME psql -U $POSTGRES_USER $DB_NAME -c "select * from pywps_requests where percent_done > -1 and percent_done < 100.0;"

set +x
echo "
Expand All @@ -27,4 +31,4 @@ Clear those jobs? (Ctrl-C to cancel, any keys to continue)"
read a

set -x
docker exec postgres psql -U $POSTGRES_USER $DB_NAME -c "delete from pywps_requests where percent_done > -1 and percent_done < 100.0;"
docker exec $POSTGRES_CONTAINER_NAME psql -U $POSTGRES_USER $DB_NAME -c "delete from pywps_requests where percent_done > -1 and percent_done < 100.0;"