气流list_dags无法用变量识别dag

时间:2020-11-12 09:47:51

标签: python airflow

我正在尝试运行airflow list_dags并且得到:

[2020-11-12 09:42:09,617] {{__init__.py:51}} INFO - Using executor SequentialExecutor
[2020-11-12 09:42:09,618] {{dagbag.py:403}} INFO - Filling up the DagBag from /usr/local/airflow/dags
[2020-11-12 09:42:09,692] {{dagbag.py:246}} ERROR - Failed to import: /usr/local/airflow/dags/my-dag/my_dag.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1248, in _execute_context
    cursor, statement, parameters, context
  File "/usr/local/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 588, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: no such table: variable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/airflow/models/dagbag.py", line 243, in process_file
    m = imp.load_source(mod_name, filepath)
  File "/usr/local/lib/python3.7/imp.py", line 171, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/local/airflow/dags/my-dag/my_dag.py", line 22, in <module>
    my_conf = Variable.get("my_conf", deserialize_json=True)
  File "/usr/local/lib/python3.7/site-packages/airflow/utils/db.py", line 74, in wrapper
    return func(*args, **kwargs)

我知道气流无法识别变量my_conf。如何从气流cli设置此变量?或者,即使存在我未设置的变量,如何使airflow list_dags工作?如果从ui设置了变量,我也会遇到同样的问题。

1 个答案:

答案 0 :(得分:0)

不确定该错误是否会解决您的问题,因为该错误似乎表明存在其他问题,请回答您的具体问题:

airflow variables -s my_conf some_value

这可以在CLI documentation中找到。