在Google Cloud Composer中浏览DAG任务信息时,气流会抛出与时区相关的TypeError



我使用具有以下定义的Google Cloud Composer运行气流DAG:

with airflow.DAG(
    'build_daily_rollups',
    default_args={
        'owner': 'airflow',
        'start_date': datetime(2019, 5, 7, 6, tzinfo=new_york_tz),
        'concurrency': 1,
        'retries': 1  # safe b/c this DAG is idempotent
    },
    schedule_interval=timedelta(hours=24),
    catchup=False
) as dag:
    roll_up_tasks = []
    for feed_id in FEEDMAP:
        task_id = f'roll_up_feed_{feed_id}'
        task = PythonOperator(
            task_id=task_id,
            params={'feed_id': feed_id, 'ts_f_strings': ts_f_strings},
            python_callable=parse_feed,
            provide_context=True
        )
        dag.add_task(task)
        roll_up_tasks.append(task)
    packager = PythonOperator(
        task_id='build_package',
        python_callable=build_package
    )
    for task in roll_up_tasks:
        task >> packager

(我正在省略parse_feed可呼叫代码,因为它与此问题不特别相关(

我触发了此DAG的手动运行。DAG进入了"运行"状态,然后什么也没有发生 - - 没有任何任务被安排甚至排队,并且DAG中每个任务的状态仍然保留在null中。尝试导航到此DAG的"任务实例详细信息"窗格后,我得到了以下错误:

Traceback (most recent call last):
  File "/opt/python3.6/lib/python3.6/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/opt/python3.6/lib/python3.6/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/opt/python3.6/lib/python3.6/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/opt/python3.6/lib/python3.6/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/opt/python3.6/lib/python3.6/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/opt/python3.6/lib/python3.6/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/opt/python3.6/lib/python3.6/site-packages/flask_admin/base.py", line 69, in inner
    return self._run_view(f, *args, **kwargs)
  File "/opt/python3.6/lib/python3.6/site-packages/flask_admin/base.py", line 368, in _run_view
    return fn(self, *args, **kwargs)
  File "/opt/python3.6/lib/python3.6/site-packages/flask_login.py", line 755, in decorated_view
    return func(*args, **kwargs)
  File "/usr/local/lib/airflow/airflow/www/utils.py", line 262, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/airflow/airflow/www/views.py", line 788, in task
    dep_context=dep_context)]
  File "/usr/local/lib/airflow/airflow/www/views.py", line 786, in <listcomp>
    failed_dep_reasons = [(dep.dep_name, dep.reason) for dep in
  File "/usr/local/lib/airflow/airflow/models.py", line 1210, in get_failed_dep_statuses
    dep_context):
  File "/usr/local/lib/airflow/airflow/ti_deps/deps/base_ti_dep.py", line 100, in get_dep_statuses
    for dep_status in self._get_dep_statuses(ti, session, dep_context):
  File "/usr/local/lib/airflow/airflow/ti_deps/deps/exec_date_after_start_date_dep.py", line 24, in _get_dep_statuses
    if ti.task.start_date and ti.execution_date < ti.task.start_date:
TypeError: can't compare offset-naive and offset-aware datetimes

此DAG定义必须是时区感知的,并且此参数化是我阅读气流文档的相关部分所获得的。此外,我能够在个人机器上的本地气流实例中成功导航到此页面。

此错误的可能原因是什么?

根据Google文档,作曲家中的气流的默认版本为1.9。从气流1.10开始支持时区注意的DAG。

您应该将气流1.10用于作曲家环境。

相关内容

  • 没有找到相关文章

最新更新