https://prefect.io logo
i

itay livni

10/19/2019, 1:42 AM
Hi - Is it possible to have a class with x number of methods as tasks?
c

Chris White

10/19/2019, 8:24 PM
Hi itay - I don’t think I understand the question; if you create a Task class by subclassing the Prefect task you can definitely add as many methods to it as you want that you can call within your run method
i

itay livni

10/19/2019, 9:30 PM
something like this
Basically a class with multiple run methods
c

Chris White

10/19/2019, 10:08 PM
Gotcha; unfortunately I don’t think this will work. What you could do instead might be:
Copy code
class BaseDefinitions(Task):
    ...
and then subclass this into two distinct Task classes with different run methods -> that way you can still reuse your other methods / logic
i

itay livni

10/19/2019, 11:13 PM
yeah - that is the conclusion I got to after mucking around a bit more