https://prefect.io logo
Title
s

Steve Vandervalk

11/21/2019, 2:25 AM
Hi all, if I am trying to run a Flow run through a normal IDE debugger but keep seeing the value of Task outputs assigned to variables as <Task:name> types, am I returning the value of tasks wrongly or using the debugger wrong?
c

Chris White

11/21/2019, 2:26 AM
Hi @Steve Vandervalk! That appears to be the repr of the task. For example, in IPython:
from prefect import Task

print(Task(name="Chris"))
# <Task: Chris>
s

Steve Vandervalk

11/21/2019, 2:27 AM
Hey! yep understood. I'm trying to do a normal debugger flow but I guess I'm unclear where the flow actually returns and assigns a Tasks output to the variable?
if that makes sense
c

Chris White

11/21/2019, 2:28 AM
hmm I don’t think I’m following quite yet; would you mind sharing a code example of what you’re referring to?
s

Steve Vandervalk

11/21/2019, 2:31 AM
with Flow("Mapbox API Travel Time Retrieval and Processing") as flow:

    download_geojson_blob_task = DownloadBlobFromAzure()

    azure_blob_name = "travel_time_segments.geojson"
    azure_container = "ottawa-mapbox-travel-time-inputs"

    travel_time_segments_geojson = download_geojson_blob_task(
        blob_name=azure_blob_name,
        azure_credentials_secret="AZ_CREDS",
        container=azure_container,
    )
...state = flow.run(executor=LocalExecutor())
something as simple as that
but not specific to instantiated tasks, functions with @task decorator are the same
c

Chris White

11/21/2019, 2:32 AM
that Flow code makes sense to me - does it not run as you expect?
s

Steve Vandervalk

11/21/2019, 2:33 AM
it runs but I'd like to insert a break point but the variable I assign a task to is that type instead of the returned dict or what have you
so I clearly don't understand something about prefect
c

Chris White

11/21/2019, 2:33 AM
gotcha; where are you inserting your breakpoint?
s

Steve Vandervalk

11/21/2019, 2:34 AM
the line after assignment say
inside the Flow
c

Chris White

11/21/2019, 2:34 AM
so Prefect builds up a deferred computational graph, meaning your code is never run until you call
flow.run
- so inputting a breakpoint within the build step of a Flow will not contain any results / data since nothing has run yet
s

Steve Vandervalk

11/21/2019, 2:35 AM
right that makes sense
should I step through then after the .run call
c

Chris White

11/21/2019, 2:35 AM
the data that is exchanged between tasks are always exchanged via Prefect States; when you call
flow.run
a Prefect State is returned whose
result
attribute is a dictionary mapping Tasks -> task states, which have a
result
attribute themselves containing the return value from that task run
s

Steve Vandervalk

11/21/2019, 2:35 AM
ah
c

Chris White

11/21/2019, 2:36 AM
so using your code above, you could do:
flow_state = flow.run()
flow_state.result[travel_time_segments_geojson].result
to actually extract the return value of that task
s

Steve Vandervalk

11/21/2019, 2:36 AM
so prefect captures it all
thanks, that's an excellent explanation
c

Chris White

11/21/2019, 2:37 AM
awesome - glad I could help!
@Marvin archive “How can I inspect the outputs from my tasks?”