5/32
Part 1 of 7 · The graphLearn and do
Start from the task list, so a task in no pair still gets a count of 0
A task that's in no pair is easy to lose. docs is the one in the pipeline:
from_pairs = {name for pair in needs for name in pair}
print(sorted(set(tasks) - from_pairs))
print(waiting["docs"], unblocks["docs"])
['docs']
0 []
dict.fromkeys(tasks, 0) gives every task a count of 0 before the loop, docs included.
unblocks is a defaultdict(list), so unblocks["docs"] reads as []. That read adds the key, the trap from the hash-maps lesson. Here it's harmless.
The editor holds graph_from_config(config), for a CI config that maps each task to the tasks it needs. Fill in its loop so it returns unblocks and waiting with a key for every task.