简体   繁体   English

从终端触发气流 DAG 不起作用

[英]Triggering an Airflow DAG from terminal not working

I'm trying to use airflow to define a specific workflow that I want to manually trigger from the command line.我正在尝试使用气流来定义我想从命令行手动触发的特定工作流程。

I create the DAG and add a bunch of tasks.我创建了 DAG 并添加了一堆任务。

dag = airflow.DAG(
    "DAG_NAME",
    start_date=datetime(2015, 1, 1),
    schedule_interval=None,
    default_args=args)

I then run in the terminal然后我在终端中运行

airflow trigger_dag DAG_NAME

and nothing happens.什么也没有发生。 The scheduler is running in another thread.调度程序正在另一个线程中运行。 Any direction is much appreciated.任何方向都非常感谢。 Thank You谢谢你

I just encountered the same issue.我刚刚遇到了同样的问题。

Assuming you are able to see your dag in airflow list_dags or via the web server then:假设您能够在airflow list_dags或通过网络服务器看到您的 dag,那么:

Not only did I have to turn on the dag in the web UI, but I also had to ensure that airflow scheduler was running as a separate process.我不仅必须在 Web UI 中打开 dag,而且还必须确保airflow scheduler作为单独的进程运行。

Once I had the scheduler running I was able to successfully execute my dag using airflow trigger_dag <dag_id>一旦我运行了调度程序,我就能够使用airflow trigger_dag <dag_id>成功执行我的 dag

My dag configuration is not significantly different from yours.我的 dag 配置与您的没有明显不同。 I also have schedule_interval=None我也有schedule_interval=None

You may have disabled the workflow.您可能已禁用工作流程。 To enable the workflow manually.手动启用工作流。 Open up the airflow web server by通过以下方式打开气流网络服务器

$ airflow webserver -p 8080

Go to http://localhost:8080 .转到http://localhost:8080 You should see the list of all available dags with a toggle button on/off.您应该看到所有可用 dag 的列表,并打开/关闭切换按钮。 By default everything is set to off.默认情况下,一切都设置为关闭。 Search for your dag and toggle your workflow.搜索您的 dag 并切换您的工作流程。 Now try triggering the workflow from terminal.现在尝试从终端触发工作流程。 It should work now.它现在应该可以工作了。

first make sure your database connection string on the airflow is working, weather it be on postgres, sqlite(by default) or any other database.首先确保气流上的数据库连接字符串正常工作,天气它在 postgres、sqlite(默认情况下)或任何其他数据库上。 Then run the command然后运行命令

 airflow initdb

This command should not be showing any connection errors此命令不应显示任何连接错误

Secondly make sure your webserver is running on a separate thread其次确保您的网络服务器在单独的线程上运行

airflow webserver

Then run your schdeuler on a different thread然后在不同的线程上运行你的 schdeuler

airflow scheduler

Finally trigger your dag on a different thread after the scheduler is running最后在调度程序运行后在不同的线程上触发你的 dag

airflow trigger_dag dag_id

Also make sure the dag name and task are present in the dag and task list还要确保 dag 名称和任务存在于 dag 和任务列表中

airflow list_dags
airflow list_tasks dag_id

And if the dag is switched off in your UI then toggle it on.如果 dag 在您的 UI 中关闭,则将其打开。

You should 'unpause' the drag you what to trigger.您应该“取消暂停”拖动您要触发的内容。 use airflow unpause xxx_drag and then airflow trigger_dag xxx_drag and it should work.使用airflow unpause xxx_drag然后airflow trigger_dag xxx_drag它应该可以工作。

气流 trigger_dag -e <execution_date> <dag_id>

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

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