我对 Airflow 很陌生。我已多次通读文档,阅读了大量 S/O 问题和许多在线随机文章,但尚未解决此问题。我有一种感觉,我做错了一些非常简单的事情。我有适用于 Windows 的 Docker,我拉取了puckel/docker-airflow
映像并运行了一个暴露端口的容器,这样我就可以从我的主机访问 UI。我有另一个容器在运行mcr.microsoft.com/mssql/server
,我在其中恢复了 WideWorldImporters 示例数据库。从 Airflow UI,我已经能够成功地创建到这个数据库的连接,甚至可以从数据分析部分查询它。
因此,虽然这有效,但我的 dag 在第二个任务中失败了sqlData。这是代码:
from airflow.models import DAG
from airflow.operators.bash_operator import BashOperator
from airflow.operators.python_operator import PythonOperator
from airflow.operators.mssql_operator import MsSqlOperator
from datetime import timedelta, datetime
copyData = DAG(
dag_id='copyData',
schedule_interval='@once',
start_date=datetime(2019,1,1)
)
printHelloBash = BashOperator(
task_id = "print_hello_Bash",
bash_command = 'echo "Lets copy some data"',
dag = copyData
)
mssqlConnection = "WWI"
sqlData = MsSqlOperator(sql="select top 100 InvoiceDate, TotalDryItems from sales.invoices",
task_id="select_some_data",
mssql_conn_id=mssqlConnection,
database="WideWorldImporters",
dag = copyData,
depends_on_past=True
)
queryDataSuccess = BashOperator(
task_id = "confirm_data_queried",
bash_command = 'echo "We queried data!"',
dag = copyData
)
最初的错误是:
*[2019-02-22 16:13:09,176] {{logging_mixin.py:95}} INFO - [2019-02-22 16:13:09,176] {{base_hook.py:83}} INFO - Using connection to: 172.17.0.3
[2019-02-22 16:13:09,186] {{models.py:1760}} ERROR - Could not create Fernet object: Incorrect padding
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/airflow/models.py", line 171, in get_fernet
_fernet = Fernet(fernet_key.encode('utf-8'))
我注意到这与密码学有关,我继续运行pip install cryptographyand pip install airflow[crytpo],两者都返回完全相同的结果,通知我要求已经得到满足。最后,我发现我只需要生成一个 fernet_key。我的airflow.cfg 文件中的默认键是fernet_key = $FERNET_KEY.
慕容3067478
相关分类