Just wondered what I should be using instead :thum...
# prefect-community
j
Just wondered what I should be using instead 👍
r
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
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
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
yup, exactly!
👍 1
j
I'm feeling the flow 🙂
marvin 2