Skip to content

charlie-goldenowl/airflow-starter

Repository files navigation

init db

 airflow db init   

create default user:

airflow users  create --role Admin --username admin --email admin --firstname admin --lastname admin --password admin

start server (terminal1) on port 0.0.0.0:8080 (default)

airflow webserver

start scheduler (terminal2)

airflow scheduler

set AIRFLOW_HOME correctly

export AIRFLOW_HOME=/Users/vuong/labs/pythonProject/airflow-starter

set dag_folder in airflow.cfg correctly

dags_folder = /Users/vuong/labs/pythonProject/airflow-starter/dags

create new dag

touch dags/hello_world_dag.py

example

#datetime
from datetime import timedelta, datetime

# The DAG object
from airflow import DAG

# Operators
from airflow.operators.empty import EmptyOperator
from airflow.operators.python import PythonOperator

# initializing the default arguments
default_args = {
		'owner': 'Ranga',
		'start_date': datetime(2022, 3, 4),
		'retries': 3,
		'retry_delay': timedelta(minutes=5)
}

# Instantiate a DAG object
hello_world_dag = DAG('hello_world_dag',
		default_args=default_args,
		description='Hello World DAG',
		schedule='* * * * *',
		catchup=False,
		tags=['example, helloworld']
)

# python callable function
def print_hello():
		return 'Hello World!'

# Creating first task
start_task = EmptyOperator(task_id='start_task', dag=hello_world_dag)

# Creating second task
hello_world_task = PythonOperator(task_id='hello_world_task', python_callable=print_hello, dag=hello_world_dag)

# Creating third task
end_task = EmptyOperator(task_id='end_task', dag=hello_world_dag)

# Set the order of execution of tasks.
start_task >> hello_world_task >> end_task

show all dags

airflow dags list

fix issues:

About

apache airflow demo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages