Jay Sundaram
04/08/2021, 2:17 PMUnexpected error: ValueError('Could not infer an active Flow context.')
Zanie
@task
def foo():
pass
with Flow() as flow:
pass
foo()
Zach Angell
from prefect import task
@task
def my_task():
print ('hi')
my_task_ = my_task()
Zanie
Zanie
Zanie
Zanie
pip install git+<https://github.com/PrefectHQ/prefect.git@improve-flow-context-err>
then try again?Jay Sundaram
04/08/2021, 2:49 PMZanie
git
installed?Zanie
pip install <https://github.com/PrefectHQ/prefect/archive/improve-flow-context-err.zip>
should work tooJay Sundaram
04/08/2021, 2:53 PMZanie
Jay Sundaram
04/08/2021, 2:55 PMZanie
task.run()
not task()
Zanie
Zanie
Jay Sundaram
04/08/2021, 2:58 PM@task()
def mytask2():
print("task 2")
@task()
def mytask1():
print("task 1")
mytask2()
with Flow('myflow') as flow:
mytask1()
reasonable?Zanie
mytask2.run()
Zanie
task()
you are creating an edge while defining a flow, not running it immediately.Jay Sundaram
04/08/2021, 3:06 PM@task()
def mytask2():
print("task 2")
return {'status': 'good'}
@task()
def mytask1():
print("task 1")
t2_results = mytask2.run()
print(f"task 2 returned status '{t2_results['status']}'")
with Flow('myflow') as flow:
mytask1()
ok, so like this.Zanie
Zanie
mytask2
so you won't get to see it in the UI and such.Jay Sundaram
04/08/2021, 3:09 PMZanie
Zanie
Jay Sundaram
04/08/2021, 3:12 PMZanie
@task
might be misleading in this case. The only reason to do so is if you intend to add it to the flow later.