Skip to main content

Version control your dbt Cloud jobs with YML.

Project description

dbt-cloud-jobs

pypi version shield CI Publish Python versions License: MIT

Version control your dbt Cloud jobs with YML.

Installation

pip install dbt-cloud-jobs

Quickstart

  1. Create an API token in dbt Cloud:

  2. Set an environment variable with the value of the token:

    export DBT_API_TOKEN="<VALUE_FROM_PREVIOUS_STEP>"
    
  3. Set an environment variable for the region where your dbt Cloud account is hosted. The value must be one of "AU", "Europe" or "US" (see docs here):

    export DBT_CLOUD_REGION="<REGION>"
    
  4. Import your existing dbt Cloud jobs:

    dbt_cloud_jobs --import --account-id 123456 --file dbt_cloud_jobs.yml
    
  5. Edit the definition of your jobs in dbt_cloud_jobs.yml.

  6. Sync the updated definitions to dbt Cloud:

    dbt_cloud_jobs --sync --file dbt_cloud_jobs.yml
    

Recommended usage in CI/CD

CI

In CI dbt-cloud-jobs should be used to verify that the provided YML file is valid. For example:

    - name: Install dbt_cloud_jobs
      run: pip install dbt-cloud-jobs

    - name: Validate `dbt_cloud_jobs.yml`
      run: dbt_cloud_jobs --validate --file dbt_cloud_jobs.yml

CD

In CD dbt-cloud-jobs should be used to sync the provided YML file to dbt Cloud. For example:

    - name: Install dbt_cloud_jobs
      run: pip install dbt-cloud-jobs

    - name: Sync `dbt_cloud_jobs.yml`
      run: dbt_cloud_jobs --sync --file dbt_cloud_jobs.yml

Example

For an example of how this package can be used, take a look at dbt-cloud-jobs-example-repo, specifically:

Limitations/Warnings

  • Service account tokens are created at the account level. This means that if you have multiple dbt Cloud accounts you will need to create different dbt_cloud_jobs.yml files for each account. If you try to use dbt-cloud-jobs with a file that contains multiple account_id values, an error will be raised.

  • ⚠️ dbt_cloud_jobs expects to "own" all the jobs in the projects where it is used. This means that if you are running dbt_cloud_jobs --sync --file dbt_cloud_jobs.yml for the first time in a project, any pre-existing jobs not present in your dbt_cloud_jobs.yml file will be deleted.

Development

To setup your development environment, fork this repository and run:

poetry shell
poetry install

Set the following environment variables:

export DBT_ACCOUNT_ID=<DBT_ACCOUNT_ID>
export DBT_CLOUD_REGION="<DBT_CLOUD_REGION>"
export DBT_ENVIRONMENT_ID=<DBT_ENVIRONMENT_ID>
export DBT_PROJECT_ID=<DBT_PROJECT_ID>
export DBT_API_TOKEN="<DBT_API_TOKEN>"

It is highly recommended that a dedicated dbt Cloud environment be used for development.

All tests can be run via:

make test

Release

Trigger the Publish to PyPi workflow, inputting the version to publish to PyPi. This workflow will:

  • Publish the version to PyPi.
  • Tag the HEAD commit of the main branches (tags visible here).
  • Create a release (releases visible here).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dbt_cloud_jobs-0.1.0.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

dbt_cloud_jobs-0.1.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file dbt_cloud_jobs-0.1.0.tar.gz.

File metadata

  • Download URL: dbt_cloud_jobs-0.1.0.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for dbt_cloud_jobs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3e515cecd37300e1759631b8a53d7b55d7e11d9bfff60fb34b0a7b3ea685b448
MD5 1792c5b36e2a26fc7de6431f26fc643d
BLAKE2b-256 459910316c434dc78afb380379dff5bcc171344135ccdbdfdc22b7b18ec800cd

See more details on using hashes here.

File details

Details for the file dbt_cloud_jobs-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dbt_cloud_jobs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b8cac90e067e9290e196de68a9d42546c2ed58a293a6b9643214c4c464dc2dd
MD5 8203b14d2213d50394e6fc9b7f7a3e97
BLAKE2b-256 12f090cd978928981d2db80b1e094d49263c9ea749d72313a24fb7c72bb5da19

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page