Get startedGet started for free

Plotting the task graph

You are trying to analyze your company's spending records. Your manager wants to see what fraction of the total spending occurred in each month. But you are going to have to run it for many files, so it would be good to set up a lazy calculation so you can speed it up using threads or processes. To figure out which of these task scheduling methods might be better for this calculation, you would like to visualize the task graph.

The totals spent in two months are available for you as delayed objects as month_1_costs and month_2_costs. dask has also been imported for you.

This exercise is part of the course

Parallel Programming with Dask in Python

View Course

Exercise instructions

  • Calculate the total spend from the two months.
  • Find the fraction of the total which was spent in the first month.
  • Find the fraction of the total which was spent in the second month.
  • Visualize the joint task graph used to compute month_1_fraction and month_2_fraction.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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
____
Edit and Run Code