1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17import asyncio from prefect.client.cloud import get_cloud_client from prefect.cli.cloud import get_current_workspace async def get_active_workspace(): async with get_cloud_client() as client: workspaces = await client.read_workspaces() current_workspace = get_current_workspace(workspaces) print(current_workspace) workspace_handle = current_workspace.split("/")[-1] print(workspace_handle) if __name__ == "__main__": asyncio.run(get_active_workspace())