Theory question: Is it possible to have a (non-tas...
# ask-community
t
Theory question: Is it possible to have a (non-task) abstract class in which the methods are tasks? I have a flow structure that gets repeated frequently for different data sets, I'm trying to create an abstract class in which the repetitive tasks are methods with the necessary text inputs, and then the 1-2 non-repetitive methods are abstract methods in the parent class and are thus implemented in child classes. The problem though is that when I do this, the @task decorators are messing with calling the methods internally. I have to pass in "self" manually, and if I need to specify any non-data dependencies (e.g. add an upstream_tasks input for the decorator) the methods seem to break whether "self" goes before or after the decorator input. Is there a way to do this? Or will this approach just not work? Really hoping there is a way since this will enable me to MASSIVELY reduce my code replication.
k
I think you will run into problems doing this (as you probably saw). You would need to wrap it in a task or pass the class around between tasks.
t
Got it, thanks! In that case maybe I just need to drop the class and make this a library of methods that I import and call individually. It's a bit clunkier but hopefully still avoids the repeats. If there's some other recommended approach here I'd love to know that too.