{"id":5158,"library":"coiled","title":"Coiled Python Client","description":"Coiled is a Python client library that simplifies scaling Python code and Dask clusters on the cloud (AWS, GCP, Azure). It handles cloud resource management, networking, and software environments, allowing data engineers and scientists to focus on their code. The library is actively maintained, with frequent updates to support new features and cloud capabilities. Its current version is 1.134.0, and it generally follows a continuous release cadence with frequent minor updates.","status":"active","version":"1.134.0","language":"en","source_language":"en","source_url":"https://github.com/coiled/coiled-python","tags":["dask","cloud-computing","distributed-computing","aws","gcp","azure","serverless"],"install":[{"cmd":"pip install \"coiled[dask]\"","lang":"bash","label":"Install with Dask"},{"cmd":"pip install coiled","lang":"bash","label":"Minimal Install"}],"dependencies":[{"reason":"Required for Dask cluster functionality, which is a primary use case.","package":"dask","optional":true},{"reason":"Dask's distributed scheduler, necessary for Dask clusters.","package":"distributed","optional":true}],"imports":[{"symbol":"Cluster","correct":"from coiled import Cluster"},{"note":"Used as a decorator for serverless functions.","symbol":"function","correct":"from coiled import function"}],"quickstart":{"code":"import coiled\nimport dask.dataframe as dd\nimport os\n\n# Ensure you are logged into Coiled via 'coiled login' in your terminal\n# and have connected your cloud account via 'coiled setup <aws|gcp|azure>'.\n\n# Quickstart for Dask Cluster\ntry:\n    cluster = coiled.Cluster(\n        n_workers=5,\n        software=\"dask-2023.12.0\", # Specify a software environment or Coiled will try to sync your local env\n        region=os.environ.get('COILED_REGION', 'us-east-1') # Use an environment variable for region\n    )\n    client = cluster.get_client()\n\n    print(f\"Dask Dashboard link: {client.dashboard_link}\")\n\n    # Example Dask computation\n    df = dd.read_csv(\"s3://dask-data/nyc-taxi/2015/yellow_tripdata_2015-01.csv\", assume_missing=True)\n    result = df.groupby('passenger_count').tip_amount.mean().compute()\n    print(\"Dask Cluster computation result:\")\n    print(result)\n\n    client.close()\n    cluster.close()\n    print(\"Dask Cluster closed.\")\n\nexcept Exception as e:\n    print(f\"Error with Dask Cluster quickstart: {e}\")\n    print(\"Please ensure you have run 'coiled login' and 'coiled setup <cloud>' and set COILED_REGION if needed.\")\n\n\n# Quickstart for Serverless Function\n# For serverless functions, you can also specify memory, cpu, region, etc.\n# e.g., @coiled.function(memory='512 GB', cpu=128, region='us-east-2')\n@coiled.function()\ndef my_serverless_function(x):\n    import time\n    time.sleep(2) # Simulate work\n    return x * 2\n\ntry:\n    print(\"\\nRunning serverless function...\")\n    future = my_serverless_function.submit(10)\n    serverless_result = future.result()\n    print(f\"Serverless function result: {serverless_result}\")\nexcept Exception as e:\n    print(f\"Error with Serverless Function quickstart: {e}\")\n    print(\"Serverless functions also require 'coiled login' and cloud setup.\")\n","lang":"python","description":"This quickstart demonstrates how to create and use a Dask cluster and a serverless Python function with Coiled. Before running, ensure you have authenticated with `coiled login` and connected your cloud account using `coiled setup <aws|gcp|azure>` via the Coiled CLI. You can specify a software environment for consistency or Coiled will attempt to synchronize your local environment."},"warnings":[{"fix":"Use `coiled.Cluster(software='my-software-environment')` or `coiled.Cluster(container='daskdev/dask:latest')` to specify a managed environment or Docker image. For serverless functions, similar options apply to the `@coiled.function` decorator.","message":"Environment synchronization can be tricky. By default, Coiled attempts to replicate your local Python environment on the remote VMs. This can sometimes lead to discrepancies if local packages are not perfectly available or compatible in the cloud environment. Explicitly defining a software environment (e.g., using `software='my-env'` or a `container='my-docker-image'`) is often more robust, especially for production or complex setups.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Run `pip install coiled` then `coiled login` and `coiled setup <your-cloud-provider>` in your terminal to authenticate and configure your cloud account.","message":"Authentication and cloud setup are prerequisites. Users must run `coiled login` and `coiled setup <aws|gcp|azure>` from their CLI before using the Python client to provision resources. Skipping these steps will result in authentication or permission errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always include `client.close()` and `cluster.close()` in your scripts when you are done with the Dask cluster. For `coiled.function` with `keepalive` set, be mindful of the duration to prevent VMs from staying active longer than needed.","message":"Resource shutdown is not automatic by default for all resources. While Coiled clusters and functions have idle timeouts, explicitly closing `client` and `cluster` objects in your script (`client.close()`, `cluster.close()`) is a good practice to release resources promptly and avoid unexpected cloud costs, especially in interactive sessions or long-running scripts.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always specify the `region` parameter when creating a `coiled.Cluster` or using `@coiled.function` to match the location of your data (e.g., `coiled.Cluster(region='us-east-2')`).","message":"Specifying cloud regions is important for data locality and cost. Not setting a specific region might lead to clusters being provisioned in a default region that is geographically distant from your data sources, incurring higher data transfer costs and increased latency.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}