Connecting the dots

So far, we've created just one task. Even on its own, it has some value, as it formalizes the work and the output. Now, let's add tasks to collect data for battle. It will look very similar to the previous one—we create a task, inheriting from the Task class:

# luigi_battles.pyfrom misc import _parse_in_depthfrom luigi_fronts import ParseFrontsclass ParseFront(luigi.Task):    front = luigi.Parameter()    def requires(self):        return ScrapeFronts()         def output(self):        path = str(folder / 'fronts' / (self.front + '.json'))        return luigi.LocalTarget(path)     def run(self):        with open(self.input().path, 'r') as f:            fronts = json.load(f)        front = fronts[self.front]        result = {}        for cp_name, campaign in front.items(): result[cp_name] = _parse_in_depth(campaign, ...

Get Learn Python by Building Data Science Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.