This message was deleted.
# ask-marvin
s
This message was deleted.
m
To fetch the flow name from a flow run id or a FlowRun object, you can use the
prefect.runtime
module within your flow code. The
flow_run
from the runtime module exposes attributes like
flow_name
that you can use in your flow. Here's an example of how you might access the flow name:
Copy code
python
from prefect import flow
from prefect.runtime import flow_run

@flow
def my_flow():
    flow_name = flow_run.flow_name
    # ... do something with the flow name ...
Regarding the deployment name, the example provided in the documentation demonstrates how to access information about the current flow run, which includes deployment details. If a flow is run as part of a deployment, the deployment name can be accessed through the runtime logs, and when run outside of a deployment, the deployment will be
None
. The logging would indicate the deployment the flow run belonged to during execution. For a full list of available attributes and how to use the runtime API, you can refer to the Prefect runtime context guide and the latest Prefect documentation: - Prefect Flows - Prefect Runtime Context - Prefect Deployments Unfortunately, these references don't seem to be sufficient to provide a code-based solution on how to fetch these details from outside a running flow. For a direct approach, you might have to query the Prefect API or use the Prefect Python client to retrieve detailed information about a flow run given its ID. If you need assistance with API queries, let me know and I'll look for specific code examples or further information.