開始使用免費開始

Variables 有點不對勁

你的主管要你調查一個問題:銷售報表沒有被產生。你最近在其中一個 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 入門

檢視課程

動手互動練習

將理論付諸實踐,立即體驗我們的互動練習

開始練習