【问题标题】:DAG Has Yet to Run - AirflowDAG 尚未运行 - 气流
【发布时间】:2022-11-02 09:58:55
【问题描述】:

我是气流新手,非常感谢对以下问题的任何帮助。 我试图在我的笔记本电脑上运行气流网络服务器。

从理论上讲,我设置了 start_time=datetime.now(),当我在网络服务器上手动运行 dag 时它应该运行成功,但它改变了超时,它已经排队或成功。 有时它是成功的(但运行时间是 00:00:00,显然我的 dag 还没有运行),有时它只是排队。

这是我的 DAG 中的代码:

from datetime import datetime
from airflow import DAG
from airflow.models import Variable
from airflow.operators.python import PythonOperator

def get_var():
    #a=Variable.get('abc')
    print('abd')

with DAG(dag_id='test_var',start_date=datetime.now()) as dag:
    task1=PythonOperator(task_id='var',python_callable=get_var)

但是,每次我在气流 webUI 中查看图表栏时,它都会显示如下图所示:

我不确定初始化气流的方式是否重要,我按照以下步骤操作:

  1. 气流网络服务器-p 8080

  2. 气流数据库初始化 --- 这两个步骤有效,但第三步 ---

  3. 气流调度器

    [2022-10-31 09:46:45,562] {scheduler_job.py:701} INFO - Starting the scheduler
    [2022-10-31 09:46:45,562] {scheduler_job.py:706} INFO - Processing each file at most -1 times
    [2022-10-31 09:46:45,565] {executor_loader.py:107} INFO - Loaded executor: SequentialExecutor
    [2022-10-31 09:46:45,569] {manager.py:163} INFO - Launched DagFileProcessorManager with pid: 13315
    [2022-10-31 09:46:45,570] {scheduler_job.py:1381} INFO - Resetting orphaned tasks for active dag runs
    [2022-10-31 09:46:46,169] {settings.py:58} INFO - Configured default timezone Timezone('UTC')
    [2022-10-31T09:46:46.172+0800] {manager.py:409} WARNING - Because we cannot use more than 1 thread (parsing_processes = 2) when using sqlite. So we set parallelism to 1.
    [2022-10-31 09:46:46 +0800] [13314] [INFO] Starting gunicorn 20.1.0
    [2022-10-31 09:46:46 +0800] [13314] [ERROR] Connection in use: ('::', 8793)
    [2022-10-31 09:46:46 +0800] [13314] [ERROR] Retrying in 1 second.
    [2022-10-31 09:46:47 +0800] [13314] [ERROR] Connection in use: ('::', 8793)
    [2022-10-31 09:46:47 +0800] [13314] [ERROR] Retrying in 1 second.
    [2022-10-31 09:46:48 +0800] [13314] [ERROR] Connection in use: ('::', 8793)
    [2022-10-31 09:46:48 +0800] [13314] [ERROR] Retrying in 1 second.
    [2022-10-31 09:46:49 +0800] [13314] [ERROR] Connection in use: ('::', 8793)
    [2022-10-31 09:46:49 +0800] [13314] [ERROR] Retrying in 1 second.
    [2022-10-31 09:46:50 +0800] [13314] [ERROR] Connection in use: ('::', 8793)
    [2022-10-31 09:46:50 +0800] [13314] [ERROR] Retrying in 1 second.
    [2022-10-31 09:46:51 +0800] [13314] [ERROR] Can't connect to ('::', 8793)
    

    结果是这样的。 这和我在 webUI 上的 DAG 操作有什么关系吗? 感谢您的时间和帮助!

    我试图搜索另一个关于 `[ERROR] Can't connect to ('::', 8793) 的 stackflow 帖子,但他们只讨论了网络服务器的内容,而且我不确定我的 dag 是否无法连接的原因'不起作用是因为气流调度程序

【问题讨论】:

  • 将 start_date 更改为非动态的,例如 datetime.now()。例如 datetime(2022, 1, 1)

标签: airflow directed-acyclic-graphs airflow-webserver


【解决方案1】:

需要运行 Airflow Scheduler 服务才能使 Airflow DAG 工作。在您的情况下,似乎另一个服务已经在使用端口 8793(调度程序的默认端口),这可能是 Airflow Scheduler 服务无法启动的原因。

考虑以下:

  1. 使用执行器 = LocalExecutor
  2. 首先使用以下命令在后台运行气流调度程序:airflow scheduler &
  3. 使用类似的东西来定义你的 start_date
    start_date = datetime.now(local_tz) - timedelta(1)

    我还建议使用 Docker 和 Docker-compose 来隔离您的环境以及与直接在笔记本电脑上运行 Airflow 相关的所有 python 依赖问题。

    我找到了这个great article。也可以参考Airflow的official documentation围绕这个。

【讨论】:

    猜你喜欢
    • 2021-05-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-06
    相关资源
    最近更新 更多