Is there any way for the code to know which enviro...
# ask-community
h
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.
s
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
Copy code
@task
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)