from airflow import DAG
from airflow.operators.bash_operator import BashOperator
from airflow.operators.python_operator import PythonOperator
from datetime import datetime, timedelta
import time

def my_python_function():
    time.sleep(60)
    print("Hello from Python!")
    

def my_python_function1():
    print("Hello from airflow!")

# 创建 DAG 对象
with DAG(
    "example_dag",
    schedule_interval='@hourly',  # 每分钟执行一次
    start_date=datetime(2022, 1, 1),
    catchup=False,
) as dag:
    task1 = PythonOperator(
        task_id="extract_data",
        python_callable=my_python_function1,
        dag=dag,
    )
    task2 = PythonOperator(
        task_id="my_python_task",
        python_callable=my_python_function,
        dag=dag,
    )
    task1 >> task2  # 定义任务的依赖关系

