Hi, I am using Prefect 1.2.1, how can I obtain the...
# prefect-community
y
Hi, I am using Prefect 1.2.1, how can I obtain the location of the result of the previous task (that uses GCSResult) - I want to pass the location of the data, not the data itself to the next task?
1
a
Many ways to solve it: 1. The easiest would be if you would return the path e.g. as a string and pass it to the downstream task as data dependency 2. Do both in your task: write to GCS and pass data itself to a downstream task that needs it 3. Use templating so that you know exactly the path:
Copy code
from prefect.engine.results import GCSResult

gcs_result = GCSResult(bucket='prefect_results', location='{flow_name}__{task_name}_xxx.pickle')

@task(result=gcs_result)
def my_task():
    ...
and just to highlight: you don't have to use GCSResult to write data to GCS, in fact I'd encourage you to build custom logic; results are mostly for recovery from failure/retry/caching and orchestration, less so for actual writing of data
y
Thanks @Anna Geller, got it!
🙌 1