Skip to content

Commit

Permalink
Merge pull request #57 from nicholasyager/feature/dbt_core_1_8
Browse files Browse the repository at this point in the history
Feature: Add support for dbt-core 1.8.0
  • Loading branch information
nicholasyager authored May 11, 2024
2 parents 5f7d1bf + bc5c04d commit b129428
Show file tree
Hide file tree
Showing 8 changed files with 588 additions and 416 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
python-version: [3.11]
poetry-version: [1.4.2]
dbt-version: [1.6.0, 1.7.0]
dbt-version: [1.6.0, 1.7.0, 1.8.0]

runs-on: ubuntu-latest

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.venv
venv/
venv-*/
dist/

__pycache__/
Expand Down
26 changes: 14 additions & 12 deletions dbt_loom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@

import yaml
from dbt.contracts.graph.node_args import ModelNodeArgs
from dbt.events.functions import fire_event
from dbt.events.types import Note


from dbt.plugins.manager import dbt_hook, dbtPlugin
from dbt.plugins.manifest import PluginNodes
from dbt.config.project import VarProvider
from dbt.node_types import NodeType

try:
from dbt.artifacts.resources.types import NodeType
except ModuleNotFoundError:
from dbt.node_types import NodeType # type: ignore


from dbt_loom.config import dbtLoomConfig
from dbt_loom.logging import fire_event
from dbt_loom.manifests import ManifestLoader, ManifestNode

import importlib.metadata
Expand Down Expand Up @@ -110,7 +116,7 @@ class dbtLoom(dbtPlugin):
def __init__(self, project_name: str):
# Log the version of dbt-loom being intialized
fire_event(
Note(msg=f'Initializing dbt-loom={importlib.metadata.version("dbt-loom")}')
msg=f'Initializing dbt-loom={importlib.metadata.version("dbt-loom")}'
)

configuration_path = Path(
Expand All @@ -125,9 +131,7 @@ def __init__(self, project_name: str):
import dbt.contracts.graph.manifest

fire_event(
Note(
msg="dbt-loom: Patching ref protection methods to support dbt-loom dependencies."
)
msg="dbt-loom: Patching ref protection methods to support dbt-loom dependencies."
)
dbt.contracts.graph.manifest.Manifest.is_invalid_protected_ref = ( # type: ignore
self.dependency_wrapper(
Expand Down Expand Up @@ -184,10 +188,8 @@ def initialize(self) -> None:

for manifest_reference in self.config.manifests:
fire_event(
Note(
msg=f"dbt-loom: Loading manifest for `{manifest_reference.name}`"
f" from `{manifest_reference.type.value}`"
)
msg=f"dbt-loom: Loading manifest for `{manifest_reference.name}`"
f" from `{manifest_reference.type.value}`"
)

manifest = self._manifest_loader.load(manifest_reference)
Expand All @@ -202,7 +204,7 @@ def get_nodes(self) -> PluginNodes:
"""
Inject PluginNodes to dbt for injection into dbt's DAG.
"""
fire_event(Note(msg="dbt-loom: Injecting nodes"))
fire_event(msg="dbt-loom: Injecting nodes")
return PluginNodes(models=self.models) # type: ignore


Expand Down
6 changes: 3 additions & 3 deletions dbt_loom/clients/dbt_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from pydantic import BaseModel
import requests
from dbt.events.functions import fire_event
from dbt.events.types import Note

from dbt_loom.logging import fire_event


class DbtCloudReferenceConfig(BaseModel):
Expand Down Expand Up @@ -41,7 +41,7 @@ def __init__(
def _query(self, endpoint: str, **kwargs) -> Dict:
"""Query the dbt Cloud Administrative API."""
url = f"{self.api_endpoint}/{endpoint}"
fire_event(Note(msg=f"Querying {url}"))
fire_event(msg=f"Querying {url}")
response = requests.get(
url,
headers={
Expand Down
11 changes: 11 additions & 0 deletions dbt_loom/logging.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
try:
import dbt_common.events.functions as dbt_event_function
from dbt_common.events.types import Note
except ModuleNotFoundError:
import dbt.events.functions as dbt_event_function # type: ignore
from dbt.events.types import Note # type: ignore


def fire_event(*args, **kwargs) -> None:
"""Fire a dbt-core event."""
dbt_event_function.fire_event(Note(*args, **kwargs))
7 changes: 5 additions & 2 deletions dbt_loom/manifests.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import datetime
import json
from typing import Dict, List, Optional, Union
from typing import Dict, List, Optional

from pydantic import BaseModel, Field, validator

from dbt.node_types import NodeType
try:
from dbt.artifacts.resources.types import NodeType
except ModuleNotFoundError:
from dbt.node_types import NodeType # type: ignore

from dbt_loom.clients.az_blob import AzureClient, AzureReferenceConfig
from dbt_loom.clients.dbt_cloud import DbtCloud, DbtCloudReferenceConfig
Expand Down
947 changes: 551 additions & 396 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ version_files = ["pyproject.toml:^version"]

[tool.poetry.dependencies]
python = ">=3.9,<4.0"
dbt-core = ">=1.6.0,<1.8.0"
dbt-core = ">=1.6.0,<=1.8.0"
requests = "^2.31.0"
google-cloud-storage = "^2.13.0"
boto3 = "^1.28.84"
Expand All @@ -25,7 +25,7 @@ types-networkx = "^3.2.1.20240313"
ruff = "^0.3.0"
pytest = "^7.4.0"
isort = "^5.12.0"
dbt-duckdb = ">=1.6.0,<1.8.0"
dbt-duckdb = ">=1.6.0,<=1.8.0"
duckdb = ">=0.8.0"
pre-commit = "^3.6.0"
mypy = "^1.8.0"
Expand Down

0 comments on commit b129428

Please sign in to comment.