Similar to what <@UMDRCSKEJ> <https://prefect-comm...
# prefect-community
a
Similar to what @Kyle Foreman (Convoy) https://prefect-community.slack.com/archives/CL09KU1K7/p1573774071310600 I'm wondering about the best way to turn task groups into re-usable parts? My problem has many flows which use almost the same task format for
A->B->C
to pull and preprocess data, then in between processing which varies by flow, then
G-H-I
to aggregate/ handle the result. It seems like
update
isn't the ideal use case for this. Right now I just have tasks in separate modules and import and run them all (so its a bit messy)
z
Hi @Aliza Rayman! My immediate thought is that parameters would be useful here. You mention that you have many flows using almost the same task format, so I'd recommend standardizing that format a bit and then parametrizing them. That should help minimize some of the import messiness you described.
a
@Zachary Hughes thanks for your input. I guess a question I sort of have is how much to parameterize. Really each of the flows has totally different logic in the inside but are run similarly using object polymorphism. So each flow gets data, populates an object, validates the object, and then generates an alert.
z
Really each of the flows has totally different logic in the inside but are run similarly using object polymorphism.
Okay, understood! So the pattern is similar, but the code itself might not be immediately reusable, if I'm understanding correctly. Regarding how much to parametrize: it's really an issue of personal preference. My general rule of thumb is to treat them like standard Python input variables: if you have one or two dictating logic, good. If you're using them to dictate wildly different logic paths, it might be better to decompose the function. As for organizing your tasks, it sounds like the best approach might be to organize them loosely into parent/child classes (PullTask, ProcessTask, etc.). Does the example in the linked documentation seem like it might be useful? https://docs.prefect.io/core/tutorials/task-guide.html#use-a-task-class-for-templating-tasks
upvote 1
a
Okay, thanks for your input! I think the docs look helpful as well