Skip to main content

An airflow DAG transformation framework

Project description

Ditto

Build Status

Ditto is a framework which allows you to do transformations to an Airflow DAG, to convert it into another DAG which is flow-isomorphic with the original DAG. i.e. it will orchestrate a flow of operators which yields the same results, but was just transformed to run in another environment or platform. The framework was built to transform EMR DAGs to run on Azure HDInsight, but you can extend the rich API for any other kind of transformation. In fact you can transform DAGs such that the result is not isomorphic too if you want (although at that point you're better off writing a whole new DAG).

The purpose of the framework is to allow you to maintain one codebase and be able to run your airflow DAGs on different execution environments (e.g. on different clouds, or even different container frameworks - spark on YARN vs kubernetes). It is not meant for a one-time transformation, but for continuous and parallel DAG deployments, although you can use it for that purpose too.

At the heart, Ditto is a graph manipulation library, which extendable APIs for the actual transformation logic. It does come with out of the box support for EMR to HDInsight transformation though.

Installation

pip install airflow-ditto

A quick example

Ditto is created for conveniently transforming a large number of DAGs which follow a similar pattern quickly. Here's how easy it is to use Ditto:

ditto = ditto.AirflowDagTransformer(DAG(
    dag_id='transformed_dag',
    default_args=DEFAULT_DAG_ARGS
), transformer_resolvers=[
    ClassTransformerResolver(
        {SlackAPIOperator: TestTransformer1,
         S3CopyObjectOperator: TestTransformer2,
         BranchPythonOperator: TestTransformer3,
         PythonOperator: TestTransformer4}
    )])

new_dag = ditto.transform(original_dag)

You can put the above call in any python file which is visible to airflow and the resultant dag loads up thanks to how airflow's dagbag finds DAGs.

Source DAG (airflow view)

simple_dag_emr

Transformed DAG

simple_dag_hdi

Read the detailed documentation here

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-ditto-0.0.1.2.tar.gz (11.1 kB view hashes)

Uploaded Source

Built Distribution

airflow_ditto-0.0.1.2-py3-none-any.whl (25.3 kB view hashes)

Uploaded Python 3

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