Dask-ML Python API Docs | dltHub
Build a Dask-ML-to-database pipeline in Python using dlt with AI Workbench support for Claude Code, Cursor, and Codex.
Last updated:
Dask-ML is a scalable machine learning library for Python that builds on Dask to run ML workloads across clusters. The REST API base URL is (varies by deployment) scheduler HTTP base is the scheduler dashboard host, e.g. https://<scheduler-host>:8787; scheduler API paths are rooted at https://<scheduler-host>:8787 (scheduler) or worker host for worker endpoints. Common API root paths: https://<scheduler-host>:8787/api/v1 and dashboard JSON endpoints under https://<scheduler-host>:8787/json or /api. and Core Dask has no built-in auth for its HTTP API; deployments may add auth (e.g., IBM Spectrum Conductor uses session login with a logon endpoint returning a session token and csrftoken cookie)..
dlt is an open-source Python library that handles authentication, pagination, and schema evolution automatically. dlthub provides AI context files that enable code assistants to generate production-ready pipelines. Install with uv pip install "dlt[workspace]" and start loading Dask-ML data in under 10 minutes.
What data can I load from Dask-ML?
Here are some of the endpoints you can load from Dask-ML:
| Resource | Endpoint | Method | Data selector | Description |
|---|---|---|---|---|
| schedulers | /schedulers | GET | (top-level array) or array of scheduler objects | List schedulers registered with manager (IBM Spectrum Conductor exposure) |
| get_workers | /api/v1/get_workers | GET | (response object contains workers map) | Get all workers on the scheduler |
| adaptive_target | /api/v1/adaptive_target | GET | (scalar/object) | Get adaptive target number of workers |
| sitemap | /sitemap.json | GET | (top-level object) | List available endpoints on the scheduler HTTP server |
| health | /health | GET | (text/json) | Health check for scheduler/worker HTTP service |
| counts | /json/counts.json | GET | (object) | Cluster counts and stats |
| identity | /json/identity.json | GET | (object) | Scheduler identity and info |
| task_stream | /api/v1/task-stream or /individual-task-stream | GET | (top-level array) | Task stream data used by dashboard |
| metrics | /metrics | GET | (Prometheus text) | Prometheus metrics endpoint |
| scheduler_info | /api/v1/scheduler_info or via client API | GET | {"workers": ...} | Scheduler state including workers map (via Client.scheduler_info or HTTP JSON endpoints) |
How do I authenticate with the Dask-ML API?
Dask core HTTP endpoints are unauthenticated by default. When deployed behind a management plane (e.g., IBM Spectrum Conductor) authentication is session-based: POST /auth/logon returns a session token (cookie) and csrftoken; subsequent modifying calls require csrftoken and the session cookie.
1. Get your credentials
There is no centralized Dask dashboard credential provider. For deployments that add auth (example IBM Spectrum Conductor): 1) Open your Spectrum Conductor / Dask manager UI. 2) Call POST /auth/logon with JSON credentials to obtain session token and csrftoken. 3) Preserve platform.rest.token cookie for subsequent requests and include csrftoken as header or query parameter for POST/PUT/DELETE. For other deployments, follow the cluster or proxy auth (OAuth, reverse proxy) instructions provided by your platform.
2. Add them to .dlt/secrets.toml
[sources.dask_ml_source] session_token = "your_session_cookie_here" csrftoken = "your_csrftoken_here"
dlt reads this automatically at runtime — never hardcode tokens in your pipeline script. For production environments, see setting up credentials with dlt for environment variable and vault-based options.
How do I set up and run the pipeline?
Set up a virtual environment and install dlt:
uv venv && source .venv/bin/activate uv pip install "dlt[workspace]"
1. Install the dlt AI Workbench:
dlt ai init --agent <your-agent> # <agent>: claude | cursor | codex
This installs project rules, a secrets management skill, appropriate ignore files, and configures the dlt MCP server for your agent. Learn more →
2. Install the rest-api-pipeline toolkit:
dlt ai toolkit rest-api-pipeline install
This loads the skills and context about dlt the agent uses to build the pipeline iteratively, efficiently, and safely. The agent uses MCP tools to inspect credentials — it never needs to read your secrets.toml directly. Learn more →
3. Start LLM-assisted coding:
Use /find-source to load data from the Dask-ML API into DuckDB.
The rest-api-pipeline toolkit takes over from here — it reads relevant API documentation, presents you with options for which endpoints to load, and follows a structured workflow to scaffold, debug, and validate the pipeline step by step.
4. Run the pipeline:
python dask_ml_pipeline.py
If everything is configured correctly, you'll see output like this:
Pipeline dask_ml_pipeline load step completed in 0.26 seconds 1 load package(s) were loaded to destination duckdb and into dataset dask_ml_data The duckdb destination used duckdb:/dask_ml.duckdb location to store data Load package 1749667187.541553 is LOADED and contains no failed jobs
Inspect your pipeline and data:
dlt pipeline dask_ml_pipeline show
This opens the Pipeline Dashboard where you can verify pipeline state, load metrics, schema (tables, columns, types), and query the loaded data directly.
Python pipeline example
This example loads schedulers and get_workers from the Dask-ML API into DuckDB. It mirrors the endpoint and data selector configuration from the table above:
import dlt from dlt.sources.rest_api import RESTAPIConfig, rest_api_resources @dlt.source def dask_ml_source(session_token=dlt.secrets.value): config: RESTAPIConfig = { "client": { "base_url": "(varies by deployment) scheduler HTTP base is the scheduler dashboard host, e.g. https://<scheduler-host>:8787; scheduler API paths are rooted at https://<scheduler-host>:8787 (scheduler) or worker host for worker endpoints. Common API root paths: https://<scheduler-host>:8787/api/v1 and dashboard JSON endpoints under https://<scheduler-host>:8787/json or /api.", "auth": { "type": "http_cookie_or_none", "session_token": session_token, }, }, "resources": [ {"name": "schedulers", "endpoint": {"path": "schedulers"}}, {"name": "get_workers", "endpoint": {"path": "api/v1/get_workers", "data_selector": "workers"}} ], } yield from rest_api_resources(config) def get_data() -> None: pipeline = dlt.pipeline( pipeline_name="dask_ml_pipeline", destination="duckdb", dataset_name="dask_ml_data", ) load_info = pipeline.run(dask_ml_source()) print(load_info)
To add more endpoints, append entries from the resource table to the "resources" list using the same name, path, and data_selector pattern.
How do I query the loaded data?
Once the pipeline runs, dlt creates one table per resource. You can query with Python or SQL.
Python (pandas DataFrame):
import dlt data = dlt.pipeline("dask_ml_pipeline").dataset() sessions_df = data.schedulers.df() print(sessions_df.head())
SQL (DuckDB example):
SELECT * FROM dask_ml_data.schedulers LIMIT 10;
In a marimo or Jupyter notebook:
import dlt data = dlt.pipeline("dask_ml_pipeline").dataset() data.schedulers.df().head()
See how to explore your data in marimo Notebooks and how to query your data in Python with dataset.
What destinations can I load Dask-ML data to?
dlt supports loading into any of these destinations — only the destination parameter changes:
| Destination | Example value |
|---|---|
| DuckDB (local, default) | "duckdb" |
| PostgreSQL | "postgres" |
| BigQuery | "bigquery" |
| Snowflake | "snowflake" |
| Redshift | "redshift" |
| Databricks | "databricks" |
| Filesystem (S3, GCS, Azure) | "filesystem" |
Change the destination in dlt.pipeline(destination="snowflake") and add credentials in .dlt/secrets.toml. See the full destinations list.
Troubleshooting
Authentication failures
If you see 401 or 403, the deployment requires authentication. For IBM Spectrum Conductor use POST /auth/logon to obtain a session token and csrftoken; include the session cookie on subsequent calls and include csrftoken for state-changing requests.
Not all endpoints available / sitemap.json
The set of HTTP endpoints served by a running scheduler/worker varies by version and config. Query /sitemap.json on the scheduler or worker host to enumerate available endpoints.
Pagination & large responses
Many dashboard JSON endpoints return complete maps or arrays (e.g., workers list). For very large clusters, responses may be large; use filtering endpoints or the Client API to fetch specific slices.
Action endpoints returning 204/500
Some control endpoints (stop worker/scheduler) return 204 No Content on success; on permission problems you may see 403; on server errors 500.
Ensure that the API key is valid to avoid 401 Unauthorized errors. Also, verify endpoint paths and parameters to avoid 404 Not Found errors.
Next steps
Continue your data engineering journey with the other toolkits of the dltHub AI Workbench:
data-exploration— Build custom notebooks, charts, and dashboards for deeper analysis with marimo notebooks.dlthub-runtime— Deploy, schedule, and monitor your pipeline in production.
dlt ai toolkit data-exploration install dlt ai toolkit dlthub-runtime install
Was this page helpful?
Community Hub
Need more dlt context for Dask-ML?
Request dlt skills, commands, AGENT.md files, and AI-native context.