小编Ste*_*ald的帖子

使用 PythonOperator 时,Airflow DAG 失败并出现“`python_callable` param must be callable”异常

损坏的 DAG:[/opt/airflow/dags/my_dag.py] 回溯(最近一次调用):文件“/home/airflow/.local/lib/python3.6/site-packages/airflow/models/baseoperator.py ”,第 179 行,在 apply_defaults result = func(self, *args, **kwargs) 文件“/home/airflow/.local/lib/python3.6/site-packages/airflow/operators/python.py”中,行136、在init中 引发AirflowException('python_callable参数必须可调用')airflow.exceptions.AirflowException:python_callable参数必须可调用

import airflow
from airflow import DAG
from airflow.operators.python import BranchPythonOperator, PythonOperator
from datetime import datetime
from random import randint
from airflow.operators.bash import BashOperator

def _training_model():
    return randint(1,11)


def _choose_best_model(ti):
    accuracies = ti.xcom_pull(task_ids =[
        'training_model_A'
        'training_model_B'
        'training_model_C'
    ])
    best_accuracy = max(accuracies)
    
    if (best_accuracy >8):
        return 'accurate'
    return 'inaccurate'

with DAG(
    dag_id="mobile_app_usage", start_date=datetime(2021,1,1),
    schedule_interval="@daily",catchup=False) as dag:

    training_model_A = PythonOperator(
        task_id = "training_model_A", …
Run Code Online (Sandbox Code Playgroud)

python airflow

-1
推荐指数
1
解决办法
4598
查看次数

标签 统计

airflow ×1

python ×1