https://prefect.io logo
#prefect-community
Title
# prefect-community
j

Jon

10/13/2022, 7:23 PM
in prefect 1, how to return a value from a flow? im calling flows via
create_flow_run
and i want to pass what i generate in the flow to a subsequent flow
✅ 2
k

Kalise Richmond

10/13/2022, 7:52 PM
Hi Jon, I think you'll need to configure results and then you'll be able to grab the results from that
j

Jon

10/13/2022, 9:06 PM
thanks @Kalise Richmond! is there a way that i can access the flow's results in memory? writing to a file is too heavy duty
perhaps there's a way to search a flow's state by uuid?
k

Kalise Richmond

10/13/2022, 9:27 PM
hey Jon, are you just looking to pass the state or are you trying to pass a value from the first flow. Here's an example that might help
j

Jon

10/13/2022, 9:55 PM
this is what i'm looking for, but the example is a bit confusing. where does the task slug come from?
Copy code
"create_some_data-1"
nvm, i have to add it
but maybe i'm doing something wrong? Seems we can't find the slug?
Copy code
Error during execution of task: ValueError("No task runs found while querying for task runs where {'task': {'slug': {'_eq': 'bronze_file'}}, 'flow_run_id': {'_eq': '5720e378-3b21-4674-8c61-198aa5951f6c'}, 'map_index': {'_eq': -1}}")
Copy code
@prefect.task(slug="bronze_file")
def generate_bronze_file():
what is the "-1" coming from here?
"create_some_data-1"
k

Kalise Richmond

10/13/2022, 10:08 PM
I believe every instance of a task gets the number appended because you can map over tasks.
j

Jon

10/13/2022, 10:09 PM
ok, so if i call the task just once in my flow it'll have a "-1"?
k

Kalise Richmond

10/13/2022, 10:09 PM
I think so. It's been a while since I've tried it out
looks like there is a
map_index
field you can use as well https://docs-v1.prefect.io/api/latest/tasks/prefect.html#get-task-run-result
j

Jon

10/13/2022, 10:11 PM
my task isn't mapped?
it works by appending "-1"
🎉 1
IMO a bit too magical 🧙
also the docs say that slugs are stable : `slug (str, optional)`: The slug for this task. Slugs provide a stable ID for tasks so that the Prefect API can identify task run states. If a slug is not provided, one will be generated automatically once the task is added to a Flow.
so kinda confusing the slug actually changes here
but thx for your help
k

Kalise Richmond

10/13/2022, 10:15 PM
Thanks for the feedback. I’ll make sure to let our doc experts know 😃
🙌 1
3 Views