Haotian Li

02/21/2023, 1:02 PM
Is there any way for the code to know which environment is it running in? I would like to write some conditionals to separate local and cloud logic.

Stéphan Taljaard

02/21/2023, 3:57 PM
I wrote this task for use in my flows. Only my Cloud flows run via deployments, so this works fine. I'm curious to see other people's approaches
async def is_running_from_deployment() -> bool:
    task_run_context = get_run_context()
    flow_run_id = task_run_context.task_run.flow_run_id

    async with get_client() as client:
        flow_run = await client.read_flow_run(flow_run_id)
        return bool(flow_run.deployment_id)