A CLI utility to poll dbt Cloud jobs and send macOS notifications
Project description
dbt Cloud Job Poller
A CLI tool to poll dbt Cloud jobs and send system (macOS) notifications about their status.
Why This Exists
When working with large dbt projects that utilize a merge queue, developers often need to wait for CI jobs to complete after syncing their branches with main before pushing changes. This tool solves two key problems:
- Manual Monitoring: Instead of repeatedly checking job status or working on other things and forgetting about your dbt job and holding up the merge queue, get notified when your specific job completes.
- Notification Control: AFAIK, dbt Cloud does not have notifications for job-specific runs. You can get notifications for all jobs of a specific environment/deployment, but not for specific ones (i.e your own CI jobs in a staging environment).
This tool solves for these! All you need is a dbt Cloud PAT, dbt Cloud account ID, and a specific Job ID, and you'll be able to watch the status of the jobn in your terminal and get notified in the macOS notification center when the job finishes.
Features
- Poll dbt Cloud jobs and monitor their status
- Cute terminal output with color-coded status updates xD
- System notifications for job completion (aka terminal sends alerts to macOS notification center)
- Configurable polling interval
- Can control the log level of the CLI output
- Somewhat detailed job status information once complete haha
Project Structure
dbt-heartbeat/
├── src/
│ ├── dbt_heartbeat.py # Main Python module/entrypoint
│ └── utils/
│ ├── __init__.py
│ ├── dbt_cloud_api.py # dbt Cloud API interactions
│ └── os_notifs.py # macOS notifs
├── pyproject.toml
└── README.md
Prerequisites
- Python 3.8 or higher
- dbt Cloud account with API access (via the dbt developer PAT)
- macOS (for system notifications)
Note: This package is designed to be installed using uv, a modern Python package installer and resolver. While uv offers improved performance and dependency management capabilities, some project dependencies (like pync) still rely on legacy build artifacts that aren't fully compatible with modern Python packaging standards. As a result, installation via pip is not currently supported, but you can use uv with pip-compatible commands like uv pip install dbt-heartbeat. The following section will guide you through the installation process using uv!
Installation - For General Use
- Add dbt environment variables to your
~/.zshrcdirectory- Refer to the guide below for global export of environment variables for all terminal sessions
- Other options are noted as well for non-global export of environment variables
- Install uv
- Check the installation with
uv --version
- Check the installation with
- Global installation of
dbt-heartbeat:- Run
uv tools install dbt-heartbeat - This will make
dbt-heartbeatglobally available on all terminal sessions
- Run
- Check the installation with
dh --version - Poll a job!
dh <job_id>
Installation - For Contributors
-
Install uv
-
Clone the repository:
git clone git@github.com:jairus-m/dbt-heartbeat.git
cd dbt-heartbeat
-
Add required environment variables in a
.envfile within your local repository's root directory -
Create and activate the virtual environment:
uv venv # initialize
uv sync # sync
source .venv/bin/activate # activate
- Run
dh <job_id> --log-level DEBUG
Configuratin Guide for Environment Variables
For global export
If you want to persist the environment variables in all terminal sessions without having to utilize a .env file or manually exporting the variables in your terminal session, you can add the export commands to your ~/.zshrc directory. (persisted)
# in ~/.zshrc
export DBT_CLOUD_API_KEY=your_dbt_cloud_api_key
export DBT_CLOUD_ACCOUNT_ID=your_dbt_cloud_account_id
For using a .env file
- Create a
.envfile in the project root with your dbt Cloud credentials - The
.envfile is scoped to the terminal session that is loaded from the same working directory (persisted in project directory)
# add these to a .env file at the root of your directory
DBT_CLOUD_API_KEY=your_api_key
DBT_CLOUD_ACCOUNT_ID=your_account_id
For exporting manually in the terminal
Or export them directly in your terminal session:
- Exporting is scoped to the specific terminal session you are in (ephemeral)
# run these in the terminal
export DBT_CLOUD_API_KEY=your_dbt_cloud_api_key
export DBT_CLOUD_ACCOUNT_ID=your_dbt_cloud_account_id
Usage
For help / version:
dh --help
dh --version
Poll a dbt Cloud job:
dh <job_run_id> [--log-level LEVEL] [--poll-interval SECONDS]
Arguments
job_run_id: The ID of the dbt Cloud job run to monitor--log-level: Set the logging level (default: INFO)- Choices: DEBUG, INFO, WARNING, ERROR, CRITICAL
--poll-interval: Time in seconds between polls (default: 30)
Example
# Poll job with default settings
dh 123456
# Poll job with debug logging and 15-second interval
dh 123456 --log-level DEBUG --poll-interval 15
Terminal Output
macOS Notification
Future Work & Limitations
- The dbt CLoud API has a runs/ endpoint that's supposed to have a
run_stepskey within thedatadict.- This would allow for dynamic output of which dbt command is running
- Unforunately, with dbt Cloud API v2, that endpoint has been unstable and is no longer populated leading to missing functionality for a better CLI status output
- I focused the notifications for my MacBook and thus, have used
pyncwhich is a wrapper forterminal-notiferfor macOS system notifications- So unfortuntaely, the current version does not support notifications for other OS systems (the CLI output should still work!)
- Unit tests...!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dbt_heartbeat-0.1.8.tar.gz.
File metadata
- Download URL: dbt_heartbeat-0.1.8.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0afdce98f459c86b5ee85eb0c37cc0438c1494834e1aa3b1d5d6c2d5957e8023
|
|
| MD5 |
ccc318340e2b3d4464759c42dcaa6653
|
|
| BLAKE2b-256 |
d5eb0070205114c480165e41a5ad39e434a1e62b52177383ba3665559a2fa646
|
File details
Details for the file dbt_heartbeat-0.1.8-py3-none-any.whl.
File metadata
- Download URL: dbt_heartbeat-0.1.8-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.7.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
adbe8a1d0412dc43a2f3cf61d2ef689c064a35a4544fcb545b821e6e6931fa7d
|
|
| MD5 |
0bf98115428cacd552a86f32d8fc5ed1
|
|
| BLAKE2b-256 |
c8c3bdda3bc805b750f5398a95b1e51e61cdfbe72a59ea3f5ae92ca79231c4d8
|