TypeError: requires() missing 1 required positional argument: 'self'

14 views
Skip to first unread message

Niko Strongioglou

unread,
Mar 9, 2022, 3:42:02 PM3/9/22
to Luigi
Hello fellow Luigi users. I am stuck on this error for quite some time now.

This is the code that breaks

def traverse_graph(self, task=None):
    if task is None:
        task = self

    requirements = luigi.task.flatten(task.requires())
    print('Requirements of {task} are {requirements}'.format(task=task, requirements=requirements))
    try:
        for subtask in requirements:
            if isinstance(subtask, ExecutionContext):
                print('Identified execution context and it is {ec}'.format(ec=subtask))
                return subtask

        for subtask in requirements:
            c = self.traverse_graph(subtask)
            if c is not None:
                return c
        return None
    except TypeError as e:
        faulty_task_methods = inspect.getmembers(task, predicate=inspect.ismethod)
        print('Type of faulty task is {t}'.format(t=type(self)))
        print('Faulty task is {fault}'.format(fault=task))
        print('Faulty task\'s methods {req}'.format(req=faulty_task_methods))
        print('Error is {r}'.format(r=e))


I have added some debug logs and understand what is going on. The tasks which produces this

- TypeError: requires() missing 1 required positional argument: 'self'

The logs are not indicative of anything going wrong: I can see that the "faulty task" is a proper instantiation of my class. I also tried using reflection (inspect) to list the methods in the "faulty task" and requires is one of them. How can a Luigi task produce such a error?

I am at my wits end here. Please help.


Reply all
Reply to author
Forward
0 new messages