https://prefect.io logo
Title
s

Sylvain Hazard

11/24/2022, 10:10 AM
Hey there ! Starting to dip my toes into Prefect 2. Was wondering if there is an equivalent to Task classes we could do in Prefect 1 where the only requirement was to override the
run
method. It felt like a good way to encapsulate complex tasks and improve code readability. Creating abstract tasks was also something I did sometimes. Is this behavior gone or has it evolved ? I couldn't find much in the docs regarding this unfortunately.
a

Anna Geller

11/24/2022, 11:01 PM
There is no imperative API in v2 but if some logic is better suited to the class-based style, then this class is likely related to some system and process to which you would likely need to store configuration and credentials data. Consider implementing a custom block for that and call that block method from a flow - the MDS blog post series and repo has examples how you can approach it
s

Sylvain Hazard

11/25/2022, 7:46 AM
Yeah that does make a lot of sense. Blocks seem more and more useful everytime I think about them 😄 Thanks !
💯 1