https://prefect.io logo
Title
z

Zach

06/29/2020, 8:47 PM
How do I add max_retries to a Task class? I modified the GCSDownloadAsFile class that inherits from GCSBaseTask class, and since this is a class, there is no @task decorator that I can add like
max_retries=3
to.
k

Kyle Moon-Wright

06/29/2020, 9:02 PM
Hey @Zach, You should be able to add that kwarg when you instantiate the custom task like this:
class AddTask(Task):
    def run(self, x, y):
        return x + y

a = AddTask(max_retries=3, retry_delay=datetime.timedelta(seconds=5))

with Flow("My Flow") as flow:
    val1 = a(1, 2)
    val2 = a(5, 7)
👍 1