【问题标题】:Airflow Task not running - unsupported operand type(s) for +: 'NoneType' and 'int'气流任务未运行 - + 不支持的操作数类型:“NoneType”和“int”
【发布时间】:2019-12-11 04:18:39
【问题描述】:

我正在尝试运行气流以将云功能部署为示例。但是当我在气流网络服务器中运行它时,我收到以下错误。

[2019-12-11 03:52:07,181] {logging_mixin.py:95} INFO - [[34m2019-12-11 03:52:07,180[0m] 
{[34mdiscovery.py:[0m867} INFO[0m - URL being requested: GET 
https://cloudfunctions.googleapis.com/v1/projects/projectid/locations/us- 
central1/functions/airflow?alt=json[0m
[2019-12-11 03:52:07,181] {taskinstance.py:1047} ERROR - unsupported operand type(s) for +: 
'NoneType' and 'int'

我的代码如下:

from airflow import DAG
from datetime import datetime, timedelta
from airflow.contrib.operators import gcp_compute_operator
from airflow.contrib.sensors import gcs_sensor 
from airflow.contrib.operators import gcp_function_operator
from google.cloud import storage
import os
import airflow
import logging

SCHEDULE_INTERVAL = '@daily'
args = {
    "owner": "airflow",
    "start_date": datetime(2019, 12, 10),
    "retries": 3
}

GCP_CONN_ID = "bq_conn_id"
dag = DAG("staging_deployment", default_args=args, 
schedule_interval=SCHEDULE_INTERVAL)

t4 = gcp_function_operator.GcfFunctionDeployOperator(
task_id="gcf_deploy2_task",
project_id="projectid",
location="us-central1",
body={
    "name":"projects/projectid/locations/us-central1/functions/airflow",
    "entryPoint":"airflow",
    "runtime":"python37",
    "sourceArchiveUrl":"gcs bucket details",
    "httpsTrigger":{}
},
validate_body=True,
dag=dag,
gcp_conn_id=GCP_CONN_ID
)
t4

请指教

【问题讨论】:

  • 变量类型肯定有问题,检查变量及其类型
  • 我认为没有声明或使用任何变量。对于明确的问题,我添加了完整的代码。目标是我在 Google 云平台的 VM 实例中运行此代码并根据代码部署云功能
  • 这是哪个 Airflow 版本?
  • 非常感谢@Sergiy 的提示,升级到气流版本起到了作用。可能与此有关github.com/CTFd/CTFd/issues/567
  • @python_interest 很高兴您能够解决问题。如果您提及您使用的 Airflow 版本以及升级到哪个版本,它可能会帮助其他人解决同样的问题。

标签: python google-cloud-platform airflow


【解决方案1】:

根据错误信息[2019-12-11 03:52:07,181] {taskinstance.py:1047} ERROR - unsupported operand type(s) for +: 'NoneType' and 'int'你必须找到文件taskinstance.py,然后搜索第1047行,看看哪个操作数变成None

您的代码太短,找不到第 1047 行,您必须粘贴较长的代码或自己做。

【讨论】:

  • taskinstance.py 来自气流本身。代码在幕后运行气流
  • @python_interest 不过,这是我开始调试错误的地方。
【解决方案2】:

非常感谢@Sergiy 的提示,升级到气流版本起到了作用。可能与此 github.com/CTFd/CTFd/issues/567 有关。我之前使用 Airflow 1.10.4 并升级到 1.10.6 。

【讨论】:

    猜你喜欢
    • 2016-09-07
    • 2018-04-16
    • 2017-12-27
    • 2014-03-31
    • 2021-05-23
    • 2015-10-15
    • 1970-01-01
    • 1970-01-01
    • 2014-11-15
    相关资源
    最近更新 更多