luigi task scheduler - access the current try count

153 views Asked by At

I'd like to know if there's a way to get the current try count dynamically, so the code will behave differently if the task is re-running, and if it's the first try.

for example - let's say this param is called <CURRENT_RUN_COUNT_PARAM>. i'd like to use it like this:

class Task(luigi.task):
    date = luigi.DateParameter()
    client = luigi.Parameter()
    retry_count = 2

def requires(self):
    return anotherTask(date=self.date, client=self.client)

def run(self):
    if <CURRENT_RUN_COUNT_PARAM> > 1:
       print('Retrying the task')
    else:
       print('First time the task is running')

any thoughts on how i can get this parameter?

0

There are 0 answers