python airflow 'NoneType'对象没有属性'is_paused',如何修复?

4xrmg8kj  于 2022-12-28  发布在  Python
关注(0)|答案(2)|浏览(172)

我是新的气流,我只是按照教程运行一个dag。实际上我做得很成功,但问题是当我试图通过输入命令行如airflow pause dag_id暂停dag时,它会抛出AttributeError: 'NoneType' object has no attribute 'is_paused'
追溯为:

File "/anaconda3/bin/airflow", line 32, in <module>
    args.func(args)
  File "/anaconda3/lib/python3.6/site-packages/airflow/utils/cli.py", line 74, in wrapper
    return f(*args, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/airflow/bin/cli.py", line 365, in pause
    set_is_paused(True, args, dag)
  File "/anaconda3/lib/python3.6/site-packages/airflow/bin/cli.py", line 379, in set_is_paused
    dm.is_paused = is_paused

所以我检查输出目录中的python文件,但是,它是由airflow编码的,我不知道如何修复它?!!!

SHOW:~ macbook$ airflow list_dags
[2018-09-07 21:31:38,262] {__init__.py:51} INFO - Using executor SequentialExecutor
[2018-09-07 21:31:38,381] {models.py:258} INFO - Filling up the DagBag from /Users/macbook/airflow/dags

-------------------------------------------------------------------
DAGS
-------------------------------------------------------------------
example_bash_operator
example_branch_dop_operator_v3
example_branch_operator
example_http_operator
example_kubernetes_executor
example_kubernetes_operator
example_passing_params_via_test_command
example_python_operator
example_short_circuit_operator
example_skip_dag
example_subdag_operator
example_subdag_operator.section-1
example_subdag_operator.section-2
example_trigger_controller_dag
example_trigger_target_dag
example_xcom
haha
latest_only
latest_only_with_trigger
test_utils
tutorial

SHOW:~ macbook$ airflow pause haha
[2018-09-07 21:35:41,366] {__init__.py:51} INFO - Using executor SequentialExecutor
[2018-09-07 21:35:41,496] {models.py:258} INFO - Filling up the DagBag from /Users/macbook/airflow/dags
Traceback (most recent call last):
  File "/anaconda3/bin/airflow", line 32, in <module>
    args.func(args)
  File "/anaconda3/lib/python3.6/site-packages/airflow/utils/cli.py", line 74, in wrapper
    return f(*args, **kwargs)
  File "/anaconda3/lib/python3.6/site-packages/airflow/bin/cli.py", line 365, in pause
    set_is_paused(True, args, dag)
  File "/anaconda3/lib/python3.6/site-packages/airflow/bin/cli.py", line 379, in set_is_paused
    dm.is_paused = is_paused
AttributeError: 'NoneType' object has no attribute 'is_paused'
omjgkv6w

omjgkv6w1#

这可能是因为DAG(tutorial.py)不在airflow需要DAG的目录中。请检查DAG是否存储在dags_folder下airflow.cfg中设置的目录中。

cnh2zyt3

cnh2zyt32#

如果您正在阅读任何使用该代码片段的文件,请确保包含完整路径。相对路径将不起作用。

相关问题