-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy_data_pavics_jupyter.env
executable file
·86 lines (70 loc) · 3.79 KB
/
deploy_data_pavics_jupyter.env
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
##############################################################################
# To use in birdhouse-deploy, source this file in env.local.
# This will generates jobs for the "deploy_data_specific_image" script found on the birdhouse/pavics-jupyter-base image.
# A job will be created for each image found in the DOCKER_NOTEBOOK_IMAGES variable,
# defined in the env.local from birdhouse-deploy.
#
# These jobs assume the "scheduler" component is enabled in birdhouse-deploy.
#
# Also, the image started by the job must contain the script "deploy_data_specific_image"
# and a yaml config file "notebook_config.yml", and they must be placed on the root directory.
# The script should be included in the pavics-jupyter-base image built from this repo.
# Each specific images deriving from this base image should include its own "notebook_config.yml" file.
##############################################################################
DEPLOY_DATA_JOB_SCHEDULE="${AUTODEPLOY_NOTEBOOK_FREQUENCY}"
DEPLOY_DATA_JOB_CONFIG="/notebook_config.yml"
# Cronjob schedule.
if [ -z "$DEPLOY_DATA_JOB_SCHEDULE" ]; then
echo "Error: DEPLOY_DATA_JOB_SCHEDULE not set" 1>&2
exit 1
#DEPLOY_DATA_JOB_SCHEDULE="3 1,4,7,10,13,16,19,22 * * *" # UTC
fi
for i in $( seq 1 $(echo $DOCKER_NOTEBOOK_IMAGES | wc -w)) ; do
DEPLOY_DATA_JOB_DOCKER_IMAGE=`echo $DOCKER_NOTEBOOK_IMAGES | cut -d " " -f $i`
DEPLOY_DATA_JOB_JUPYTERHUB_IMAGE_NAME=`echo $JUPYTERHUB_IMAGE_SELECTION_NAMES | cut -d " " -f $i`
DEPLOY_DATA_JOB_JOB_NAME="notebookdeploy-${DEPLOY_DATA_JOB_JUPYTERHUB_IMAGE_NAME}"
DEPLOY_DATA_JOB_JOB_DESCRIPTION="Auto-deploy tutorial notebooks for the image ${DEPLOY_DATA_JOB_DOCKER_IMAGE}"
# Docker image to run deploy-date script.
if [ -z "$DEPLOY_DATA_JOB_DOCKER_IMAGE" ]; then
echo "Error: DEPLOY_DATA_JOB_DOCKER_IMAGE not set" 1>&2
exit 1
fi
# Name of the image found on the JupyterHub selection page, important for the path of the volume mount
if [ -z "$DEPLOY_DATA_JOB_JUPYTERHUB_IMAGE_NAME" ]; then
echo "Error: DEPLOY_DATA_JOB_JUPYTERHUB_IMAGE_NAME not set" 1>&2
exit 1
fi
# Log file location. Default location under /var/log/PAVICS/ has built-in logrotate.
if [ -z "$DEPLOY_DATA_JOB_LOGFILE" ]; then
DEPLOY_DATA_JOB_LOGFILE="${PAVICS_LOG_DIR}/${DEPLOY_DATA_JOB_JOB_NAME}.log"
fi
if [ -z "`echo "$AUTODEPLOY_EXTRA_SCHEDULER_JOBS" | grep $DEPLOY_DATA_JOB_JOB_NAME`" ]; then
# Add job only if not already added (config is read more than once during
# autodeploy process).
LOGFILE_DIRNAME="`dirname "$DEPLOY_DATA_JOB_LOGFILE"`"
# Path where notebooks are deployed on the image running the script
DEPLOY_DATA_JOB_NOTEBOOK_DEST_DIR=${JUPYTERHUB_USER_DATA_DIR}/tutorial-notebooks-specific-images/${DEPLOY_DATA_JOB_JUPYTERHUB_IMAGE_NAME}
export AUTODEPLOY_EXTRA_SCHEDULER_JOBS="
$AUTODEPLOY_EXTRA_SCHEDULER_JOBS
- name: $DEPLOY_DATA_JOB_JOB_NAME
comment: $DEPLOY_DATA_JOB_JOB_DESCRIPTION
schedule: '$DEPLOY_DATA_JOB_SCHEDULE'
command: '/deploy_data_specific_image /notebook_config.yml'
dockerargs: >-
--rm --name $DEPLOY_DATA_JOB_JOB_NAME
--volume ${DEPLOY_DATA_JOB_NOTEBOOK_DEST_DIR}:${DEPLOY_DATA_JOB_NOTEBOOK_DEST_DIR}:rw
--volume ${LOGFILE_DIRNAME}:${LOGFILE_DIRNAME}:rw
--env DEPLOY_DATA_LOGFILE=${DEPLOY_DATA_JOB_LOGFILE}
--env DEPLOY_DATA_JOB_NOTEBOOK_DEST_DIR=${DEPLOY_DATA_JOB_NOTEBOOK_DEST_DIR}
--user 0:0
image: ${DEPLOY_DATA_JOB_DOCKER_IMAGE}
"
fi
# Reset all config vars to prevent cross-contamination between successive invocations.
DEPLOY_DATA_JOB_JOB_NAME=""
DEPLOY_DATA_JOB_LOGFILE=""
DEPLOY_DATA_JOB_JOB_DESCRIPTION=""
DEPLOY_DATA_JOB_DOCKER_IMAGE=""
DEPLOY_DATA_JOB_JUPYTERHUB_IMAGE_NAME=""
done
# vi: tabstop=8 expandtab shiftwidth=4 softtabstop=4