hey <@ULVA73B9P> is it possible to see what work q...
# ask-marvin
s
hey @Marvin is it possible to see what work queue a flow run is running in from the flow run itself?
m
Yes, it's possible to see what work queue a flow run is running in from the flow run itself. According to the Prefect documentation, the flow run page should show the deployment, work pool, and work queue status. For more detailed information, you can refer to the work pools documentation. Additionally, here is a relevant GitHub issue describing the visibility of work queue status on the flow run page: https://github.com/PrefectHQ/prefect/issues/12170
s
@Marvin Can i do it from python code?
m
Yes, you can access the work queue a flow run is running in from Python code. You can use the Prefect API client to retrieve this information. Here's a simplified example:
Copy code
python
from prefect.client.orion import get_client
from prefect.orion.schemas.core import FlowRun

async def get_work_queue_from_flow_run(flow_run_id):
    async with get_client() as client:
        flow_run = await client.read_flow_run(flow_run_id)
        deployment = await client.read_deployment(flow_run.deployment_id)
        work_queue_name = deployment.work_queue_name
        
        return work_queue_name

# Example usage:
# import asyncio
# asyncio.run(get_work_queue_from_flow_run("<YOUR_FLOW_RUN_ID"))
In this script, you replace
"<YOUR_FLOW_RUN_ID>"
with the ID of your flow run. This will fetch the work queue name associated with the deployment of the flow run. For more details, you can refer to the Prefect documentation on using the client. Here are some relevant code examples: - Basic usage of `@flow`: https://raw.githubusercontent.com/zzstoatzz/prefect-code-examples/main/examples/flows/basic.py
s
thank you