Joseph Haaga
10/23/2020, 7:39 PMflow
only defined inside that contexthandler/`with` statement?
from prefect import task, Flow
@task
def say_hello():
print("Hello, world!")
with Flow("Run Me") as flow:
h = say_hello()
flow.run() # prints "Hello, world!"
I’m getting the following
NameError: name 'flow' is not defined
Alexander
10/23/2020, 7:41 PM[2020-10-23 19:42:19] INFO - prefect.FlowRunner | Beginning Flow run for 'Run Me'
[2020-10-23 19:42:19] INFO - prefect.TaskRunner | Task 'say_hello': Starting task run...
Hello, world!
[2020-10-23 19:42:19] INFO - prefect.TaskRunner | Task 'say_hello': finished task run for task with final state: 'Success'
[2020-10-23 19:42:19] INFO - prefect.FlowRunner | Flow run SUCCESS: all reference tasks succeeded
Please check your environmentBilly McMonagle
10/23/2020, 8:27 PMflow
exists outside of the with
block. The resource which is aliased as flow
is "open" for the duration of the with
block, and "closed" upon exiting the with
block, but the object itself persists and can have methods called.Joseph Haaga
10/23/2020, 8:29 PM__exit__()
gets called; interesting - thanks!