From reading other messages I am aware the statefu...
# ask-community
e
From reading other messages I am aware the statefulness classes does not work well with class method as tasks or flows. I have however written my python code using classes, I like them for keeping my code in manageable segments. As long as I do not need to pass any self attributes from when task to another I assume I am ok to use a class? I am thinking I have a separate
prefect-flow.py
file that imports my class. Should I create an instance in the flow and pass to each task? Or create a class instance in each task?
n
Hey @eddy davies! Could you provide an example of what you mean by this?
the statefulness classes does not work well with class method as tasks or flows
I'm not sure what you mean by
statefulness classes
a
Eddy, you may consider creating a custom block if you need to store some configuration to external system that needs to be reused across various methods
e
@Nate Sorry, I meant “statefulness of classes”. I am just referring to this discussion. @Anna Geller Good idea if I need to pass something between tasks.
🙌 1
n
Ahh gotcha, thanks for the context I would recommend importing your class into your file where your flow will be defined, and wrapping useful calls of class's methods with
@task
or
@flow
when you need orchestration on some of your class functionality
💙 1
🎯 1
e
perfect prefect advise, just the conclusion i was coming to, just wanted some reassurance, much appreciated
👍 1