开始使用免费开始使用

变量不太对劲

您的主管请您排查一个销售报告未生成的问题。您最近在一个 Dag(process_sales)中实现了变量功能,该 Dag 会处理一些杂项销售数据,并写出主管关心的报告。查看日志时,您发现文件没有写到预期位置,而是写到了默认位置。

处理报告的任务如下所示:

@task()
  def parse_file():
    output_path = Variable.get("Output_Path", default="/home")
    output_fn = Variable.get("Output_Filename", default="sales_report.pdf")
    save_file("{output_path}/{output_fn}")

文件应当保存为 /data/sales/sales_report.pdf

请尝试运行命令 airflow dags test process_sales 来查看日志输出。

以下哪个说法最能解释错误原因?您会如何修复?

本练习是课程的一部分

Python 中的 Apache Airflow 入门

查看课程

动手互动练习

通过我们的互动练习之一,将理论转化为实践

开始练习