Git Product home page Git Product logo

airflow-materials's Introduction

The Complete Hands-On Introduction to Apache Airflow

Practice of the course: The Complete Hands-On Introduction to Apache Airflow.

Table of Contents

  1. Prerequisites
  2. Install Apache Airflow with Docker
  3. Install dependencies
  4. Create Connections
  5. Debug DAG

Prerequisites

  1. Download Docker.
  2. Download PyCharm Community Edition or Visual Studio Code.

Docker needs privilege rights to work, make sure you have them. If you have troubles to install these tools, here are some videos to help you

Install Apache Airflow with Docker

  1. Open your terminal or CMD and go into airflow-materials

  2. Create .env with:

AIRFLOW_IMAGE_NAME=apache/airflow:2.4.2
AIRFLOW_UID=50000
  1. In terminal run:
docker-compose up -d
  1. Open AirFlow in the browser: localhost:8080
Username: airflow
Password: airflow

Install dependencies

  1. Apache Airflow
pip install apache-airflow
  1. Apache AirFlow Providers Postgres
pip install apache-airflow-providers-postgres
  1. pandas
pip install pandas 

Create Connections

  1. Postgres
Connection Id: postgres
Connection Type: Postgres
Host: postgres
Login: airflow
Password: airflow
Port: 5432
  1. HTTP
Connection Id: user_api
Connection Type: HTTP
Host: https://randomuser.me/
Login: airflow
Password: airflow

Debug DAG

List your docker containers

docker-compose ps

Access to the scheduler bash

docker exec -it airflow-materials-airflow-scheduler-1 /bin/bash

Check the commands and execute task test

airflow -h
airflow tasks test user_processing create_table
airflow tasks test user_processing extract_user 2022-01-01
airflow tasks test user_processing process_user 2022-01-01

Access to the worker

docker exec -it airflow-materials-airflow-worker-1 /bin/bash

Check worker files

ls /tmp

Access to the postgres sql

docker exec -it airflow-materials-postgres-1 /bin/bash 

Enter into psql

psql -Uairflow

Then show the data into users table

SELECT * FROM users;

Section 6: Databases and Executors

docker cp airflow-materials-airflow-scheduler-1:/opt/airflow/airflow.cfg .
docker-compose down
docker-compose up -d

Section 8: Creating Airflow Plugins with Elasticsearch and PostgreSQL

docker compose -f docker-compose-es.yaml up -d
docker compose -f docker-compose-es.yaml ps
docker exec -it airflowmaterials-airflow-scheduler-1 /bin/bash
curl -X GET 'http://elastic:9200'
  1. Elastic
Connection Id: elastic_default
Connection Type: HTTP
Host: elastic
Port: 9200

Restart docker to add ElasticHook

docker-compose -f docker-compose-es.yaml stop
docker compose -f docker-compose-es.yaml up -d
docker exec -it airflowmaterials-airflow-scheduler-1 /bin/bash
airflow plugins

airflow-materials's People

Contributors

gastonsingh avatar

Stargazers

Julio Spairani avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.