https://prefect.io logo
j

James Phoenix

10/22/2020, 3:56 PM
Just wondered what I should be using instead 👍
r

Raphaël Riel

10/22/2020, 5:09 PM
I would go with something like this:
Copy code
# define Prefect flow
with Flow("Test Flow", schedule=schedule) as flow:
    realtor_data = extract()
    houston_realtor_data = transform()
    load_to_database = load()


flow_state = flow.run()
result = flow_state.result[houston_realtor_data].result
print(result)
upvote 3
Otherwise, you can print from the Task itself using
log_stdout=True
.
Copy code
@task
def extract(log_stdout=True):
    # download and return a list of all texas realtors
    print(result)
    return result
upvote 4
c

Chris White

10/22/2020, 5:33 PM
Hi @James Phoenix +1 to Raphael’s answer; for more context, remember that Prefect is built on a deferred execution model, which means that task results are not available until run time, but your print statement is executing at build time before any results are available. Something worth keeping in mind, as it can be a common stumbling block! (For another example, check out: https://stackoverflow.com/questions/64155793/is-it-possible-to-loop-over-a-prefect-parameter)
j

James Phoenix

10/22/2020, 5:41 PM
Oh okay I've got it. Basically there is a build time in the flow which creates the DAG.
But then all of the variables are actually executed after the flow has been run 👍
c

Chris White

10/22/2020, 5:41 PM
yup, exactly!
👍 1
j

James Phoenix

10/22/2020, 5:57 PM
I'm feeling the flow 🙂
marvin 2