Skip to main content

An opinionated implementation of exclusively using airflow DockerOperators for all Operators

Project description

airflow-docker

CircleCI Codacy Badge codecov

Description

An opinionated implementation of exclusively using airflow DockerOperators for all Operators.

Default Operator

from airflow_docker.operator import Operator

task = Operator(
    image='some-image:latest',
    ...
)

Default Sensor

from airflow_docker.operator import Sensor

sensor = Sensor(
    image='some-image:latest',
    ...
)

Task Code

from airflow_docker_helper import client

client.sensor(True)

Branch Operator

Dag Task

from airflow_docker.operator import BranchOperator

branching_task = BranchOperator(
    image='some-image:latest',
    ...
)

Task Code

from airflow_docker_helper import client

client.branch_to_tasks(['task1', 'task2'])

Short Circuit Operator

Dag Task

from airflow_docker.operator import ShortCircuitOperator

short_circuit = ShortCircuitOperator(
    image='some-image:latest',
    ...
)

Task Code

from airflow_docker_helper import client

client.short_circuit()  # This task will short circuit if this function gets called

Context Usage

Dag Task

from airflow_docker.operator import Operator

task = Operator(
    image='some-image:latest',
    provide_context=True,
    ...
)

Task Code

from airflow_docker_helper import client

context = client.context()

Configuration

The following operator defaults can be set under the airflowdocker namespace:

  • force_pull (boolean true/false)
  • auto_remove (boolean true/false)
  • network_mode

For example, to set force_pull to False by default set the following environment variable like so:

export AIRFLOW__AIRFLOWDOCKER__FORCE_PULL=false

Plugin

This package works as an airflow plugin as well. When installed and running airflow, dags can import like so

from airflow.{type, like "operators", "sensors"}.{name specificed inside the plugin class} import *

i.e.

from airflow.operators.airflow_docker import Operator

Tests

We also ship an airflowdocker/tester image to verify the integrity of your DAG definitions before committing them.

One can run the tests against your own dags like so:

docker run -it -v "${pwd}/dags:/airflow/dags" airflowdocker/tester

or else see the airflow-docker-compose project which ships with a test subcommand for precisely this purpose.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

airflow-docker-2.0.3.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

airflow_docker-2.0.3-py2.py3-none-any.whl (20.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file airflow-docker-2.0.3.tar.gz.

File metadata

  • Download URL: airflow-docker-2.0.3.tar.gz
  • Upload date:
  • Size: 17.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.6.11

File hashes

Hashes for airflow-docker-2.0.3.tar.gz
Algorithm Hash digest
SHA256 c87d9b0a2518cfb9f12e61ec7d4a53df302d3c09cb30e5aef07c7fa8ae906234
MD5 27fc0fc9ce3ed66c0372f9f4248eb64c
BLAKE2b-256 52be6ef64019e28d8b97000334e929e8faf6d2bf3b972e80e1bb5ab38af22778

See more details on using hashes here.

Provenance

File details

Details for the file airflow_docker-2.0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: airflow_docker-2.0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/49.3.1 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.6.11

File hashes

Hashes for airflow_docker-2.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f1140382660ede91d5cc9c7796d8956c01f528c707b040d1359ec818c5bbda97
MD5 bf32432628301544176a5dbd5900a797
BLAKE2b-256 3d213779a5e7a5bf32182d0087491969eacf58a32f811d02e291cc9e49760b01

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page