Skip to content

Support dbt 1.9 #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Feb 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 26 additions & 28 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,22 @@ jobs:
- '3.11'
- '3.10'
- '3.9'
- '3.8'
airflow-version:
- '2.9.2'
- '2.8.4'
- '2.7.3'
- '2.10'
- '2.9'
- '2.8'
dbt-version:
- 1.9
- 1.8
- 1.7
exclude:
# Incompatible combinations
- python-version: 3.12
airflow-version: '2.8.4'

- python-version: 3.12
airflow-version: '2.7.3'
airflow-version: '2.8'

runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@v2.8.1
uses: step-security/harden-runner@v2.10.4
with:
egress-policy: block
allowed-endpoints: >
Expand All @@ -54,6 +50,7 @@ jobs:
hub.getdbt.com:443
github.com:80
github.com:443
gitlab.com:22
gitlab.com:80
gitlab.com:443
objects.githubusercontent.com:443
Expand All @@ -64,28 +61,29 @@ jobs:
esm.ubuntu.com:443
motd.ubuntu.com:443
packages.microsoft.com:80
packages.microsoft.com:443
ppa.launchpadcontent.net:443
security.ubuntu.com:80

- run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends postgresql

- uses: actions/checkout@v4.1.7
- uses: actions/checkout@v4.2.2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5.1.0
uses: actions/setup-python@v5.4.0
with:
python-version: ${{ matrix.python-version }}

- name: Install Poetry
uses: abatilo/actions-poetry@v2.3.0
uses: abatilo/actions-poetry@v2.4.0
with:
poetry-version: 1.8.3
poetry-version: 2.0.1

- name: Install Airflow & dbt
run: |
poetry env use ${{ matrix.python-version }}
poetry add "apache-airflow==${{ matrix.airflow-version }}" \
poetry add "apache-airflow~=${{ matrix.airflow-version }}.0" \
"dbt-core~=${{ matrix.dbt-version }}.0" \
"dbt-postgres~=${{ matrix.dbt-version }}.0" \
--python ${{ matrix.python-version }}
Expand All @@ -99,14 +97,14 @@ jobs:
- name: Static type checking with mypy
# We only run mypy on the latest supported versions of Airflow & dbt,
# so it is currently impossible to write conditions for that depend on package versions.
if: matrix.python-version == '3.12' && matrix.airflow-version == '2.9.2' && matrix.dbt-version == '1.8'
if: matrix.python-version == '3.12' && matrix.airflow-version == '2.10' && matrix.dbt-version == '1.9'
run: poetry run mypy .

- name: Code formatting with black
run: poetry run black --check .

- name: Set COVERAGE_FILE in environment
run: echo "COVERAGE_FILE=.coverage.${{ matrix.python-version }}.${{ matrix.airflow-version }}" >> $GITHUB_ENV
run: echo "COVERAGE_FILE=.coverage.${{ matrix.python-version }}-${{ matrix.airflow-version }}-${{ matrix.dbt-version }}" >> $GITHUB_ENV

- name: Run tests with pytest
run: poetry run coverage run -m pytest -v tests/ airflow_dbt_python/utils/
Expand All @@ -117,11 +115,11 @@ jobs:
GITHUB_USERNAME: ${{ secrets.GH_USERNAME }}

- name: Upload code coverage
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-data
name: coverage-data-${{ matrix.python-version }}-${{ matrix.airflow-version }}-${{ matrix.dbt-version }}
path: ".coverage.*"
if-no-files-found: ignore
include-hidden-files: true

coverage:
name: Combine and check coverage
Expand All @@ -130,7 +128,7 @@ jobs:

steps:
- name: Harden Runner
uses: step-security/harden-runner@v2.8.1
uses: step-security/harden-runner@v2.10.4
with:
egress-policy: block
allowed-endpoints: >
Expand All @@ -139,23 +137,23 @@ jobs:
api.github.com:443
pypi.org:443

- uses: actions/checkout@v4.1.7
- uses: actions/setup-python@v5.1.0
- uses: actions/checkout@v4.2.2
- uses: actions/setup-python@v5.4.0
with:
python-version: '3.12'

- name: Install Poetry
uses: abatilo/actions-poetry@v2.3.0
uses: abatilo/actions-poetry@v2.4.0
with:
poetry-version: 1.8.3
poetry-version: 2.0.1

- name: Install airflow-dbt-python with Poetry
run: poetry install --with dev -E airflow-providers

- name: Download coverage data.
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage-data
merge-multiple: true

- name: Combine coverage & fail if it's <95%.
run: |
Expand All @@ -171,7 +169,7 @@ jobs:
poetry run coverage report --fail-under=95

- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: ${{ failure() }}
with:
name: html-report
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/docs_pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
with:
fetch-depth: 0

- name: Set up Python '3.10'
uses: actions/setup-python@v2
- name: Set up Python '3.12'
uses: actions/setup-python@v5.4.0
with:
python-version: '3.10'
python-version: '3.12'

- name: Install Poetry
uses: abatilo/actions-poetry@v2.1.4
uses: abatilo/actions-poetry@v2.4.0
with:
poetry-version: 1.3.2
poetry-version: 2.0.1

- name: Install airflow-dbt-python with Poetry
run: poetry install -E airflow-providers --with docs
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/pypi_deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.10
uses: actions/setup-python@v2
- name: Set up Python 3.12
uses: actions/setup-python@v5.4.0
with:
python-version: '3.10'
python-version: '3.12'

- name: Install Poetry
uses: abatilo/actions-poetry@v2.1.4
uses: abatilo/actions-poetry@v2.4.0
with:
poetry-version: 1.3.2
poetry-version: 2.0.1

- name: Install airflow-dbt-python with Poetry
run: poetry install
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tagged_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ jobs:
uses: actions/checkout@v2.3.4

- name: Set up Python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v5.4.0
with:
python-version: '3.10'

- name: Install Poetry
uses: abatilo/actions-poetry@v2.1.4
uses: abatilo/actions-poetry@v2.4.0
with:
poetry-version: 1.3.2
poetry-version: 2.0.1

- name: Install airflow-dbt-python with Poetry
run: poetry install
Expand Down
19 changes: 14 additions & 5 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
version: 2

build:
os: "ubuntu-22.04"
os: "ubuntu-lts-latest"
tools:
python: "3.11"
python: "3.12"
apt_packages:
- graphviz
jobs:
post_install:
- pip install poetry==1.3.2
- poetry config virtualenvs.create false
pre_install:
- python -m pip install poetry==2.0.1
- poetry config virtualenvs.create false --local
- poetry install -E git -E s3 --with docs
- poetry export -E git -E s3 --with docs -f requirements.txt --without-hashes --output docs/requirements.txt

python:
install:
- requirements: docs/requirements.txt

sphinx:
builder: dirhtml
configuration: docs/conf.py
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Read the [documentation](https://airflow-dbt-python.readthedocs.io) for examples
## Requirements

Before using *airflow-dbt-python*, ensure you meet the following requirements:
* A *dbt* project using [dbt-core](https://pypi.org/project/dbt-core/) version 1.7.5 or later.
* An Airflow environment using version 2.7 or later.
* A *dbt* project using [dbt-core](https://pypi.org/project/dbt-core/) version 1.8 or later.
* An Airflow environment using version 2.8 or later.

* If using any managed service, like AWS MWAA or GCP Cloud Composer 2/3, ensure your environment is created with a supported version of Airflow.
* If self-hosting, Airflow installation instructions can be found in their [official documentation](https://airflow.apache.org/docs/apache-airflow/stable/installation/index.html).
Expand Down
2 changes: 1 addition & 1 deletion airflow_dbt_python/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
__author__ = "Tomás Farías Santana"
__copyright__ = "Copyright 2021 Tomás Farías Santana"
__title__ = "airflow-dbt-python"
__version__ = "2.1.0"
__version__ = "2.2.0"
10 changes: 1 addition & 9 deletions airflow_dbt_python/hooks/dbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
from airflow.hooks.base import BaseHook
from airflow.models.connection import Connection

from airflow_dbt_python.utils.version import DBT_INSTALLED_GTE_1_8

if sys.version_info >= (3, 11):
from contextlib import chdir as chdir_ctx
else:
Expand Down Expand Up @@ -400,13 +398,7 @@ def setup_dbt_logging(self, task: BaseTask, debug: Optional[bool]):
default_stdout. As these are initialized by the CLI app, we need to
initialize them here.
"""
if DBT_INSTALLED_GTE_1_8:
from dbt.events.logging import setup_event_logger
else:
from dbt.events.functions import ( # type: ignore[no-redef]
setup_event_logger,
)

from dbt.events.logging import setup_event_logger
from dbt.flags import get_flags

flags = get_flags()
Expand Down
Loading
Loading