Skip to main content

Provides a powerful, Django-inspired class-based DAG syntax for Apache Airflow.

Project description

Workflows

Workflows are a cleaner way of implementing DAGs using a Django-inspired class-based syntax.

Simple Example

Let's create a single Airflow DAG, whose name is a camelcased version of the class name, and whose operator dependencies are in the order they are defined.

There is an option to override the default dependencies method implementation to customise the dependency chain for your use case.

import workflows


class ExampleWorkflow(workflows.Workflow):
    class Meta:
        schedule_interval = '0 9 * * *'

    do_something_useful = workflows.PythonOperator(
        python_callable=lambda **kwargs: print('something useful'),
    )
    something_else = workflows.PythonOperator(
        python_callable=lambda **kwargs: print('Something not useful'),
    )


globals()[ExampleWorkflow.DAG.dag_id] = ExampleWorkflow.DAG

Dynamic DAG Example

Let's create (in this case three) DAGs, created dynamically and based on the ExampleWorkflow class as implemented above. In other words, they will share the same DAG metadata (so schedule in this case).

import workflows

workflow_names = [
    'Test1',
    'Test2',
    'Test3',
]

for workflow in workflow_names:
    WorkflowClass = workflows.create_workflow(
        workflow,
        base=ExampleWorkflow,
    )
    globals()[WorkflowClass.DAG.dag_id] = WorkflowClass.DAG

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-workflows-0.1.4.tar.gz (3.6 kB view details)

Uploaded Source

File details

Details for the file airflow-workflows-0.1.4.tar.gz.

File metadata

  • Download URL: airflow-workflows-0.1.4.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for airflow-workflows-0.1.4.tar.gz
Algorithm Hash digest
SHA256 f6810b8c298397e3328355e17c2b0b46eddfcea868a7a1591078025620a99816
MD5 98be40213eb7cd82569b440fa8d38049
BLAKE2b-256 0b722df75f19eb1fb9d8333deb58994829d483b8476e049533867dccf72872a2

See more details on using hashes here.

Supported by

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