Hi all, I am using a Context class to maintain st...
# ask-the-community
c
Hi all, I am using a Context class to maintain state between the tasks but I am unable to do so, as after every task the instance is refreshed.
context = Context()
task1_result = task1(context=context)
task2_result = task2(context=context)
# In task 1
def task1(context:Context):
context.name="user"
# In task 2
def task2(context:Context):
print(context)
I am getting None values in task2 for context
n
In Flyte, tasks are run as independent containers, so you can’t pass state from one task to another in this way. The only way to do it is by passing data through workflows.
k
You should return context from task1 and then use it in task2