開始使用免費開始

繪製任務圖

你正在分析公司支出紀錄。主管想看到每個月的支出佔總支出的比例。由於你要對很多檔案重複執行,最好先建立延遲計算,之後才能用多執行緒或多製程加速。為了判斷哪一種任務排程方式較適合這個計算,你想先把任務圖視覺化。

兩個月的總支出已提供為延遲物件,分別是 month_1_costsmonth_2_costsdask 也已經幫你匯入。

本練習屬於課程

在 Python 中使用 Dask 進行平行程式設計

檢視課程

練習說明

  • 計算兩個月的總支出。
  • 找出第一個月佔總支出的比例。
  • 找出第二個月佔總支出的比例。
  • 視覺化用來計算 month_1_fractionmonth_2_fraction 的聯合任務圖。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Add the two delayed month costs
total_costs = ____

# Calculate the fraction of total cost from month 1
month_1_fraction = ____

# Calculate the fraction of total cost from month 2
month_2_fraction = ____

# Plot the joint task graph used to calculate the fractions
____
編輯並執行程式碼