简体   繁体   English

运行Airflow DAG的问题

[英]Issues running Airflow DAG

I have been working on Apache Airflow for a while now to schedule my workflow. 我已经在Apache Airflow上工作了一段时间,以安排我的工作流程。 I seem to be having issues scheduling my DAG. 我似乎在安排DAG时遇到问题。 I have been using this SO question for reference : Airflow not scheduling Correctly Python 我一直在使用这个SO问题作为参考: Airflow不能正确调度Python

from airflow import DAG 
from airflow.operators.bash_operator import BashOperator
from datetime import datetime
from datetime import timedelta

default_args = {
    'owner': 'airflow',
    'depends_on_past': False,
'start_date': datetime.now() - timedelta(minutes=5),
'email': ['airflow@airflow.com'],
'email_on_failure': False,
'email_on_retry': False,
'retries': 1,
'retry_delay': timedelta(minutes=5),
}

 dag = DAG('dag_mkdir_folder', default_args=default_args,
      schedule_interval=timedelta(minutes=5))


 task_hello = BashOperator(task_id='print_hello',
                      bash_command='mkdir test_airflow', dag=dag)

I'm trying to run the task using the following list of commands : 我正在尝试使用以下命令列表运行任务:

 airflow scheduler
 airflow trigger_dag dag_mkdir_folder

I keep getting this as an error : 我不断得到这个错误:

[2017-05-15 13:49:06,688] {models.py:322} DagFileProcessor406 INFO -      Finding 'running' jobs without a recent heartbeat
[2017-05-15 13:49:06,689] {models.py:328} DagFileProcessor406 INFO -   Failing jobs without heartbeat after 2017-05-15 13:44:06.689284

The bash command is just supposed to create a new directory. bash命令仅应创建一个新目录。 The test version works fine. 测试版本工作正常。

Run the scheduler on a different terminal and then trigger your dag in another terminal 在另一个终端上运行调度程序,然后在另一个终端上触发dag

also try providing your full path where you want to make the directory. 也请尝试提供要创建目录的完整路径。 For example creating folder in the airflow directory: 例如,在airflow目录中创建文件夹:

task_hello = BashOperator(task_id='print_hello',
                  bash_command="mkdir ~/airflow/test_airflow", dag=dag)

This should create test_airflow folder inside airflow 这应该在气流内部创建test_airflow文件夹

Your current bash_command is telling Airflow to create a directory inside of the temporary directory that the DAG uses when it is running, which it blows away along with all of its contents after the DAG is run. 您当前的bash_command告诉Airflow在DAG运行时使用的临时目录内创建一个目录,该目录将在DAG运行后随其所有内容一起消失。

Consider changing directories to the directory you want to create it in. 考虑将目录更改为要在其中创建目录。

A bash_command with that would look something like: 一个bash_command如下所示:

"cd <path_to_directory>; mkdir test_airflow"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM