Hi prefect community. Where can I find the result ...
# ask-community
j
Hi prefect community. Where can I find the result storage path for the previous flow run on Prefect Cloud UI? For a flow shown in the image, there is no result storage path information in the flow run history when persist_result=True and with result_storage path in the webUI. I remember prefect used to have it somewhere but now its gone.
s
@Marvin please answer the question above.
m
To retrieve the task run ID from a flow run in Prefect, the process differs between versions 2.x and 3.x. Here's how you can accomplish this for both versions: ### Prefect 2.x You can retrieve metadata including the run ID by using Prefect tasks and functions to interact with the flow context. Here's a simple example from the Prefect 2.x documentation:
Copy code
python
from prefect import flow
from prefect.context import get_run_context

@flow
def my_flow():
    context = get_run_context()
    flow_run_id = context.flow_run.id
    print(f"Flow Run ID: {flow_run_id}")

my_flow()
For additional details, you can refer to the Prefect 2.x runtime context guide. ### Prefect 3.x The Prefect 3.x documentation provides ways to access runtime information directly. Here's how you can achieve that:
Copy code
python
from prefect import flow
from prefect.runtime import flow_run

@flow
def my_flow():
    run_id = flow_run.id
    print(f"Flow Run ID: {run_id}")

my_flow()
You can find more information in the Prefect 3.x runtime context documentation. ### Useful Documentation Links: - Prefect 2.x Runtime Context - Prefect 3.x Runtime Context If you encounter any specific issues or need more advanced examples, feel free to let me know!
s
@Marvin what about the result storage path for the previous flow run on Prefect Cloud UI?
m
To retrieve the result storage path for a previous flow run on Prefect Cloud UI, here's how to approach it for both versions. ### Prefect 2.x In Prefect 2.x, results can be persisted to a storage location such as S3, Local, etc. If you want to find the storage path of a previous flow run result in the Prefect Cloud UI, you will typically look at the result storage configuration defined in your flow and task. Here's an example setup:
Copy code
python
from prefect import flow, task
from prefect.filesystems import S3

@flow(result_storage=S3(bucket_path="my-bucket"))
def my_flow():
    my_task()

@task(persist_result=True, result_storage_key="my_task.json")
def my_task():
    return "Task result"

my_flow()
In this case, the task's result will be persisted to 's3://my-bucket/my_task.json'. For more details, check out the Prefect 2.x Results documentation. ### Prefect 3.x In Prefect 3.x, result storage is similarly configured using blocks. The result storage path can be specified for the flow and tasks. You can review these paths in the Prefect Cloud UI under the specific flow runs details. Here's a sample setup:
Copy code
python
from prefect import flow, task

@flow(result_storage='s3-bucket/my-dev-block')
def my_flow():
    my_task()

@task(persist_result=True, result_storage_key="my_task.json")
def my_task():
    return "Task result"

my_flow()
By defining
result_storage
in the flow and
result_storage_key
in the task, you can control where the results are stored. The results in this case would be found under the specified S3 bucket. For more sophisticated configurations and details, refer to the Prefect 3.x Results documentation. ### Accessing the Storage Path in the Prefect Cloud UI To see the result storage path for a previous flow run in the Prefect Cloud UI: 1. Navigate to the specific flow run. 2. Look for result information or associated storage blocks/details in the flow run metadata. ### Useful Documentation Links: - Prefect 2.x Results Storage - Prefect 3.x Results Storage Feel free to ask if you need more specific instructions or run into any issues!