Skip to content

steinsag/apache-airflow-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apache Airflow Test

I created this small example to test Python workflow engine Apache Airflow.

Requirements

Setup

Those steps need to be done only ones:

  • create MySQL DB and user to access it

      mysql -u root -p
      
      CREATE DATABSE airflow;
      CREATE USER 'airflow'@'%' IDENTIFIED BY 'airflow';
      GRANT ALL PRIVILEGES ON 'airflow'.* TO 'airflow'@'%' WITH GRANT OPTION;
      FLUSH PRIVILEGES;
    
  • test MySQL connection:

      mysql -u airflow -p airflow
    
  • create virtual environment:

      virtualenv env -p python3
      
      or
      
      virtualenv env -p python2
    
  • enter virtual environment:

      source env/bin/activate
      export AIRFLOW_HOME=.
    
  • install all dependencies:

      pip install -r requirements.txt
    
  • initialize database:

      airflow initdb
    

Execute Airflow

Airflow consists of two major components, which must be started in order to execute and manage workflows:

  • webserver - web app to manage workflows
  • scheduler - component instantiating and executing workflows

In both cases, one needs to first enter the virtual environment:

source env/bin/activate
export AIRFLOW_HOME=.

Airflow webserver can be started as follows:

airflow webserver

The web app is now available at: http://localhost:8080/

Airflow scheduler can be started as follows:

airflow scheduler

Trigger New Workflow Instance

This example project defines one workflow type SAMPLE_WORKFLOW_TYPE in dags/sample_workflow_types.py.

To instantiate this workflow type, enter virtual environment and trigger workflow instantiation via command line:

source env/bin/activate
export AIRFLOW_HOME=.

airflow trigger_dag SAMPLE_WORKFLOW_TYPE --conf '{"inputAttribute1": "input value 1", "inputAttribute2": "input value 2"}'

About

Small sample project to test Apache Airflow workflow engine.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages