Skip to content

Repository files navigation

data-services

data-services

A place to add Data Services scripts from PO's. Data services are scripts which are used to process incoming data on a per pipeline basis in the data ingestion pipelines.

Licensing

This project is licensed under the terms of the GNU GPLv3 license.

Folder stucture

The suggested naming convention we agreed on with the developers, regarding the different PO's scripts was : [FACILITY_NAME]/[SUB-FACILITY_NAME]_[script_name]

example : FAIMMS/faimms_data_rss_channels_process

Injected Environment Variables

During the deployment of data services (see chef recipe), various environment variables are made available for cronjobs (they may or may not be used). Using them will result in more relocatable and robust scripts.

The environment variables are:

NameDefaultPurpose
$ARCHIVE_DIR/mnt/ebs/archiveArchive
$ARCHIVE_IMOS_DIR/mnt/ebs/archiveArchive
$INCOMING_DIR/mnt/ebs/incomingIncoming
$ERROR_DIR/mnt/ebs/errorDir. to store incoming files that cause pipeline errors
$WIP_DIR/mnt/ebs/wipWork In Progress tmp dir
$DATA_SERVICES_DIR/mnt/ebs/data-servicesWhere this git repo is deployed
$DATA_SERVICES_TMP_DIR/mnt/ebs/tmpTemp dir for data services work (not on root partition like /tmp)
$EMAIL_ALIASES/etc/incoming-aliasesList of configured aliases
$PYTHONPATH$DATA_SERVICES_DIR/lib/pythonLocation of data-services python scripts/modules
$LOG_DIR/mnt/ebs/log/data-servicesDesignated log dir
$HARVESTER_TRIGGERsudo -u talend /mnt/ebs/talend/bin/talend-trigger -c /mnt/ebs/talend/etc/trigger.confCommand to trigger talend
$S3CMDs3cmd --config=/mnt/ebs/data-services/s3cfgDefault parameters for the s3cmd utility
$S3_BUCKETLocation of the S3 bucket for this environment

It may be necessary to source additional environment variables that are defined elsewhere. For example, the location of the schema definitions which are defined in the pipeline databags can be sourced from /etc/profile.d/pipeline.sh.

Mocking Environment

In order to mock your environment so you can test things, you can have a script called env.sh for example with the contents of:

export ARCHIVE_DIR='/tmp/archive'
export INCOMING_DIR='/tmp/incoming'
export WIP_DIR='/tmp/wip'
export DATA_SERVICES_DIR="$PWD"
export LOG_DIR='/tmp/log'
mkdir -p $ARCHIVE_DIR $INCOMING_DIR $WIP_DIR $LOG_DIR

Then to test your script with the mocked environment you can run:

$ (source env.sh && YOUR_SCRIPT.sh)

Configuration

Cronjobs

Cronjobs for data-services scripts are managed via chef databags under chef-private/data_bags/cronjobs

Cronjobs are prefixed with po_ in order to differentiate them from other non pipeline-related tasks.

The cronjob must source any necessary environment variables first, followed by your command or script e.g.:

0 21 *** projectofficer source /etc/profile &&$DATA_SERVICES_DIR/yourscript.py

Example data_bag. chef-private/data_bags/cronjobs/po_NRMN.json

{
"job_name": "po_NRMN",
"shell": "/bin/bash",
"minute": "0",
"hour": "21",
"user": "projectofficer",
"command": "source /etc/profile; $DATA_SERVICES_DIR/NRMN/extract.sh",
"mailto": "benedicte.pasquer@utas.edu.au",
"monitored": true
}

The following attributes can be used:

KeyTypeDescriptionDefault
['job_name']StringThe ID/name of the cronjob (mandatory)
['shell']StringThe shell to use for the script/command (mandatory)
['user']StringUser that will run the script/command (mandatory)
['command']StringCommand or script to be run (must be valid bash and must be able to resolve path)
['mailto']StringUser to send report of cronjob command output toroot@localhost
['monitored']BooleanDetermines whether Nagios will monitor the job or not
['minute']Stringminute to run job on (see crontab syntax below)*
['hour']Stringhour to run job on (see crontab syntax below)*
['day']Stringday to run job on (see crontab syntax below)*
['month']Stringmonth to run job on (see crontab syntax below)*
['weekday']Stringweekday to run job on (see crontab syntax below)*

Crontab syntax:

# m h dom mon dow command# .---------------- minute (0 - 59)# | .------------- hour (0 - 23)# | | .---------- day of month (1 - 31)# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# | | | | |# * * * * * user-name command to be executed
0 22 ***$username script.path/script.sh

Your cronjobs need to be defined in the node attributes of the chef-managed node before they will be installed. e.g.:

"cronjobs": [
"po_NRMM",
"po_someother_job",
"..."
]

About

Scripts which are used to process incoming data in the data ingestion pipeline

Resources

Stars

1 star

Watchers

19 watching

Forks

Releases

Packages

Used by

Contributors

Languages