绘制任务图
您正在分析公司的支出记录。经理想要查看每个月的支出占总支出的比例。由于您需要对许多文件执行同样的操作,最好设置懒计算,这样就可以用多线程或多进程来加速。为判断哪种任务调度方式更适合本次计算,您希望把任务图可视化。
两个月的总支出已经以延迟对象的形式提供,分别为 month_1_costs 和 month_2_costs。dask 也已为您导入。
本练习是课程的一部分
Python 中的 Dask 并行编程
练习说明
- 计算两个月的总支出。
- 计算第 1 个月支出占总支出的比例。
- 计算第 2 个月支出占总支出的比例。
- 可视化用于计算
month_1_fraction和month_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
____