Skip to main content
Version: 1.33.0 (latest) View Markdown

Workspace setup

A workspace ready for the dltHub platform is a regular Python project with a few additions. You can easily convert any existing dlt project into a dltHub workspace. What is a workspace explains the local workspace, the remote workspace and its deployments.

Starting from scratch instead? Use uvx dlthub-start@latest, which scaffolds a workspace and runs a first pipeline for you — see Deploy your first pipeline.

1. Enable dltHub platform features​

Initialize the workspace:

uvx dlthub-init@latest

uvx dlthub-init@latest scaffolds a ready-to-run workspace—the .dlt/.workspace marker that turns on workspace mode, local config and secrets, a managed pyproject.toml, and the dltHub AI skills your coding agent uses—then installs dependencies with uv sync.

The .dlt/.workspace marker activates profile support and enables the dlthub CLI command (including dlthub profile and dlthub local). Run uvx dlthub-init@latest --help for options like --no-sync. If you'd rather flip the toggle by hand, see Enable workspace mode.

The AI Harness keeps what its toolkits produce in a separate folder, .dlthub/. See Artifact locations.

2. Log in to the dltHub platform​

dlthub login

This opens your browser and authenticates the current user. On a remote session, where no browser can reach your machine, use dlthub login --device for the device-code flow. The login does not connect the workspace.

3. Connect to a remote workspace​

You can connect the local workspace to the dltHub platform so that you can deploy it:

dlthub workspace connect [<workspace>] [--org-id <org_id>]

With no argument, an interactive picker is shown, grouped by organization. Here dlt connects the local workspace to a workspace deployment in the default environment, prod, and writes the chosen workspace_id (and organization_id, on the first connect) to .dlt/config.toml. To list the workspaces that you have access to, use dlthub workspace list.

note

The first time you run dlthub deploy, dlthub run, or dlthub serve, the CLI walks you through GitHub OAuth and then prompts you to pick (or create) a workspace — so you can skip steps 2 and 3 entirely.

organization_id is write-once. To switch organizations later, remove the line from .dlt/config.toml by hand and run dlthub workspace connect again.

One workspace deployment for each environment​

In each environment, the local workspace is connected to a workspace deployment of its own and deploys there. So prod and staging never share jobs, job runs or credentials. All workspace deployments of a local workspace belong to one organization.

dlt keeps the connections in the shared config.toml, one section for each environment:

# .dlt/config.toml
[runtime]
organization_id = "..." # one organization for the whole workspace

[workspace.environment.prod]
workspace_id = "..." # written by `dlthub workspace connect`

[workspace.environment.staging]
workspace_id = "..." # written by the first deployment to `staging`

dlt writes these sections for you. dlthub workspace connect connects the local workspace in the environment of the active profile, else in the default environment. Name another one with --environment. The first deployment to another environment connects the local workspace in that environment.

A workspace deployment is named after the local workspace and the environment: the workspace ingest deploys to ingest-staging in staging. The default environment keeps the plain workspace name. To use another name, set name in the section of the environment, as name under [workspace.settings] names the local workspace.

dlthub profile list shows the workspace deployment of each environment. dlthub profile info shows the one of the active profile.

caution

In each environment, a local workspace is connected to only one workspace deployment at a time. If you connect it to a different one, the jobs deployed under the previous connection are deactivated. Their run history stays, but their triggers no longer fire.

Connecting multiple local repositories to the same workspace deployment is not yet supported.

Connect from CI​

CI sets the same values with environment variables, WORKSPACE__ENVIRONMENT__STAGING__WORKSPACE_ID for example. For non-interactive auth (CI, scripts), set api_key in secrets.toml under [runtime] instead of relying on the OAuth flow. api_base_url defaults to https://api.dlthub.com and only needs to be set when targeting a self-hosted control plane.

Workspaces connected before dlt 1.33.0​

A workspace that was connected before dlt 1.33.0 keeps the id of its workspace deployment as workspace_id under [runtime] in config.toml. dlt still reads it as the workspace deployment of the default environment, and nothing needs to change. dlthub workspace connect moves it to [workspace.environment.prod], and dlthub workspace disconnect removes it. If both are set, even to the same id, dlt stops with an error: remove workspace_id under [runtime].

The same key in the settings file of a profile of another environment, stg.config.toml for example, connects the local workspace in that environment until its section has a workspace_id. In the settings file of a profile of the default environment, it counts as the one in config.toml. RUNTIME__WORKSPACE_ID, which the platform and CI set, always wins.

4. Add pipelines​

dlthub pipeline init <source> <destination>

This reuses the same machinery as dlt init, so verified sources and templates work as you'd expect. See Initialize a pipeline for templates, verified sources, and the agentic setup.

5. Set up destinations for each profile​

A profile holds the credentials and settings that the code runs with. A new workspace declares the local profiles dev and tests and, in the prod environment, the remote profiles prod, access and no-access. How profiles work says what each one is for.

You can give the destination a name in your pipeline and let each profile say what the name means. First create the settings files of the profiles. A new workspace has only .workspace, config.toml and secrets.toml:

dlthub profile add dev
dlthub profile add prod

dev.config.toml (local DuckDB):

[destination.warehouse]
destination_type = "duckdb"

prod.config.toml (production destination):

[destination.warehouse]
destination_type = "motherduck"

prod.secrets.toml (read/write credentials for batch jobs):

[destination.warehouse.credentials]
database = "your_database"
password = "your-motherduck-service-token"

Here the same destination="warehouse" resolves to DuckDB with dev and to MotherDuck with prod: a setting in the file of a profile overrides the shared config.toml. You can swap MotherDuck for any cloud destination, see for example BigQuery, Snowflake, or filesystem/S3.

Interactive jobs such as notebooks read with access. Until access has settings files, they run with prod. To give them read-only credentials, see Limit the data access of jobs.

Security

Files matching *.secrets.toml and secrets.toml are gitignored by default. Never commit secrets to version control. The dltHub platform stores your secrets securely when you sync your configuration.

Next steps​

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.