Apache Airflow definitions for OpenTrials
10K+
Airflow is a platform to programmatically author, schedule and monitor workflows.
When workflows are defined as code, they become more maintainable, versionable, testable, and collaborative.
Use Airflow to author workflows as directed acyclic graphs (DAGs) of tasks. The Airflow scheduler executes your tasks on an array of workers while following the specified dependencies. Rich command line utilities make performing complex surgeries on DAGs a snap. The rich user interface makes it easy to visualize pipelines running in production, monitor progress, and troubleshoot issues when needed.
An Airflow container can be built with
docker build -t opentrials/opentrials-airflow .
and pushed to Docker hub with
docker push opentrials/opentrials-airflow
A single task, e.g. spark, of an Airflow dag, e.g. example, can be run with an execution date, e.g. 2016-01-01, in the dev environment with:
ansible-playbook ansible/deploy_local.yml -e '@ansible/envs/dev.yml' -e "command='test example spark 20160101'"
The container will run the desired task to completion (or failure). Note that if the container is stopped during the execution of a task, the task will be aborted. In the example's case, the Spark job will be terminated.
The logs of the task can be inspected in real-time with:
docker logs -f files_scheduler_1
Assuming you are on OS X, first create a docker machine with a sufficient amount of memory with e.g.:
docker-machine create -d virtualbox --virtualbox-memory 4096 default
To deploy the Airflow container on the docker engine, with its required dependencies, run:
ansible-playbook ansible/deploy_local.yml -e '@ansible/envs/dev.yml'
echo "Airflow web console should now be running locally at http://$(docker-machine ip default):8080"
Note that this will start running all the DAGs with a start date in the past! To avoid that do not pass the AWS credentials.
If you get a message saying "Couldn't connect to Docker daemon - you might need to run docker-machine start default.", try the following:
docker-machine start default
eval "$(docker-machine env default)"
You can now connect to your local Airflow web console with a URL like http://192.168.99.100:8080 (see above for how to identify the exact IP address).
To deploy to our Docker Cloud, run:
make deploy
This requires the Vault's password file to be located on ./.vault_pass, so
Ansible is able to decrypt the production variables.
Our Airflow instance will need a few configuration variables and connections to be able to run the supplied DAGs. Please follow the CONFIGURATION.md file in order to know what those variable mean and how to use them.
Some useful docker tricks for development and debugging:
# Stop all docker containers:
docker stop $(docker ps -aq)
# Remove any leftover docker volumes:
docker volume rm $(docker volume ls -qf dangling=true)
main_summary DAG tree view.main_summary or crash_aggregates2016-07-14 00:00:002016-07-20 00:00:05scheduled__2016-07-14T00:00:00docker psdocker exec -it <container_id> bash. The webserver instance is a good choice.$ airflow backfill main_summary -s 2016-06-20 -e 2016-06-26This repository is heavily based on https://github.com/mozilla/telemetry-airflow
Content type
Image
Digest
Size
625.4 MB
Last updated
about 9 years ago
docker pull okibot/opentrials-airflow