Skip to content

Commit

Permalink
Merge pull request #316 from godatadriven/support-artifacts-0.8
Browse files Browse the repository at this point in the history
Support dbt-artifacts-parser>=0.8
  • Loading branch information
pgoslatara authored Dec 19, 2024
2 parents 03f81ad + 9e117a8 commit 68b9f10
Show file tree
Hide file tree
Showing 10 changed files with 284 additions and 278 deletions.
474 changes: 237 additions & 237 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 @@ -83,7 +83,7 @@ version = "0.0.0"
[tool.poetry.dependencies]
python = ">=3.9,<3.14"
click = "<9"
dbt-artifacts-parser = "<0.8"
dbt-artifacts-parser = ">=0.8"
jinja2 = "^3"
jinja2-simple-tags = "^0"
levenshtein = ">=0.26.1"
Expand Down Expand Up @@ -165,7 +165,7 @@ indent-width = 4
target-version = "py38"

[tool.ruff.lint]
ignore = ["COM812", "D100", "D203", "D213", "D406", "D407", "D409", "E501", "G004", "S101"]
ignore = ["COM812", "D100", "D203", "D213", "D406", "D407", "D409", "E501", "G004", "LOG015", "S101"]
preview=true
select = ["A", "ARG", "B", "C4", "COM", "D", "DOC", "E", "EXE", "F", "I", "ICN", "LOG", "G", "N", "PT", "PTH", "Q", "RUF", "S", "SIM", "T20", "TCH", "TID", "W"]
unfixable = ["B"]
Expand Down
4 changes: 2 additions & 2 deletions scripts/generate_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
def build_pex_file(dbt_version, pex_file_name):
"""Build a pex file of `dbt-bouncer` if it does not already exist."""
if not Path(pex_file_name).exists():
logging.info(f"Building pex file for dbt version {dbt_version}") # noqa: LOG015
logging.info(f"Building pex file for dbt version {dbt_version}")
sh.poetry(
[
"run",
Expand Down Expand Up @@ -42,7 +42,7 @@ def generate_artifacts(
pex_file_name,
):
"""Generate dbt artifacts for all specified versions of dbt. These artifacts are used in testing."""
logging.info(f"Generating dbt artifacts for dbt version {dbt_version}") # noqa: LOG015
logging.info(f"Generating dbt artifacts for dbt version {dbt_version}")
Path(artifact_path).mkdir(exist_ok=True, parents=True)
sh.python(
[
Expand Down
6 changes: 4 additions & 2 deletions src/dbt_bouncer/artifact_parsers/parsers_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning)
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import (
CatalogTable,
CatalogV1,
)
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import (
Nodes as CatalogNodes,
)
if TYPE_CHECKING:
from pathlib import Path

Expand All @@ -24,7 +26,7 @@
class DbtBouncerCatalogNode(BaseModel):
"""Model for all nodes in `catalog.json`."""

catalog_node: CatalogTable
catalog_node: CatalogNodes
original_file_path: str
unique_id: str

Expand Down
8 changes: 5 additions & 3 deletions src/dbt_bouncer/checks/catalog/check_catalog_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,16 @@

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning)
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import CatalogTable
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import (
Nodes as CatalogNodes,
)


class CheckSourceColumnsAreAllDocumented(BaseCheck):
"""All columns in a source should be included in the source's properties file, i.e. `.yml` file.
Receives:
catalog_source (CatalogTable): The CatalogTable object to check.
catalog_source (CatalogNodes): The CatalogNodes object to check.
sources (List[DbtBouncerSourceBase]): List of DbtBouncerSourceBase objects parsed from `catalog.json`.
Other Parameters:
Expand All @@ -36,7 +38,7 @@ class CheckSourceColumnsAreAllDocumented(BaseCheck):
"""

catalog_source: "CatalogTable" = Field(default=None)
catalog_source: "CatalogNodes" = Field(default=None)
name: Literal["check_source_columns_are_all_documented"]
sources: List["DbtBouncerSourceBase"] = Field(default=[])

Expand Down
24 changes: 13 additions & 11 deletions src/dbt_bouncer/checks/catalog/check_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning)
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import CatalogTable
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import (
Nodes as CatalogNodes,
)
from dbt_bouncer.artifact_parsers.parsers_manifest import (
DbtBouncerModelBase,
DbtBouncerTestBase,
Expand All @@ -23,7 +25,7 @@ class CheckColumnDescriptionPopulated(BaseCheck):
"""Columns must have a populated description.
Receives:
catalog_node (CatalogTable): The CatalogTable object to check.
catalog_node (CatalogNodes): The CatalogNodes object to check.
models (List[DbtBouncerModelBase]): List of DbtBouncerModelBase objects parsed from `manifest.json`.
Other Parameters:
Expand All @@ -40,7 +42,7 @@ class CheckColumnDescriptionPopulated(BaseCheck):
"""

catalog_node: "CatalogTable" = Field(default=None)
catalog_node: "CatalogNodes" = Field(default=None)
models: List["DbtBouncerModelBase"] = Field(default=[])
name: Literal["check_column_description_populated"]

Expand Down Expand Up @@ -69,7 +71,7 @@ class CheckColumnHasSpecifiedTest(BaseCheck):
test_name (str): Name of the test to check for.
Receives:
catalog_node (CatalogTable): The CatalogTable object to check.
catalog_node (CatalogNodes): The CatalogNodes object to check.
tests (List[DbtBouncerTestBase]): List of DbtBouncerTestBase objects parsed from `manifest.json`.
Other Parameters:
Expand All @@ -87,7 +89,7 @@ class CheckColumnHasSpecifiedTest(BaseCheck):
"""

catalog_node: "CatalogTable" = Field(default=None)
catalog_node: "CatalogNodes" = Field(default=None)
column_name_pattern: str
name: Literal["check_column_has_specified_test"]
test_name: str
Expand Down Expand Up @@ -126,7 +128,7 @@ class CheckColumnNameCompliesToColumnType(BaseCheck):
types (List[str]): List of data types to check.
Receives:
catalog_node (CatalogTable): The CatalogTable object to check.
catalog_node (CatalogNodes): The CatalogNodes object to check.
Other Parameters:
exclude (Optional[str]): Regex pattern to match the model path. Model paths that match the pattern will not be checked.
Expand Down Expand Up @@ -166,7 +168,7 @@ class CheckColumnNameCompliesToColumnType(BaseCheck):
"""

catalog_node: "CatalogTable" = Field(default=None)
catalog_node: "CatalogNodes" = Field(default=None)
column_name_pattern: str
name: Literal["check_column_name_complies_to_column_type"]
types: List[str]
Expand All @@ -187,7 +189,7 @@ class CheckColumnsAreAllDocumented(BaseCheck):
"""All columns in a model should be included in the model's properties file, i.e. `.yml` file.
Receives:
catalog_node (CatalogTable): The CatalogTable object to check.
catalog_node (CatalogNodes): The CatalogNodes object to check.
models (List[DbtBouncerModel]): List of DbtBouncerModel objects parsed from `manifest.json`.
Other Parameters:
Expand All @@ -203,7 +205,7 @@ class CheckColumnsAreAllDocumented(BaseCheck):
"""

catalog_node: "CatalogTable" = Field(default=None)
catalog_node: "CatalogNodes" = Field(default=None)
models: List["DbtBouncerModelBase"] = Field(default=[])
name: Literal["check_columns_are_all_documented"]

Expand All @@ -225,7 +227,7 @@ class CheckColumnsAreDocumentedInPublicModels(BaseCheck):
"""Columns should have a populated description in public models.
Receives:
catalog_node (CatalogTable): The CatalogTable object to check.
catalog_node (CatalogNodes): The CatalogNodes object to check.
models (List[DbtBouncerModel]): List of DbtBouncerModel objects parsed from `manifest.json`.
Other Parameters:
Expand All @@ -241,7 +243,7 @@ class CheckColumnsAreDocumentedInPublicModels(BaseCheck):
"""

catalog_node: "CatalogTable" = Field(default=None)
catalog_node: "CatalogNodes" = Field(default=None)
models: List["DbtBouncerModelBase"] = Field(default=[])
name: Literal["check_columns_are_documented_in_public_models"]

Expand Down
2 changes: 1 addition & 1 deletion src/dbt_bouncer/config_file_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ def validate_conf(
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning)
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import (
CatalogTable, # noqa: F401
Nodes as CatalogNodes, # noqa: F401
)
if "manifest_checks" in check_categories:
import dbt_bouncer.checks.manifest
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/checks/catalog/test_catalog_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning)
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import CatalogTable
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import Nodes as CatalogNodes

from dbt_bouncer.artifact_parsers.dbt_cloud.manifest_latest import Sources
from dbt_bouncer.artifact_parsers.parsers_manifest import (
Expand All @@ -22,7 +22,7 @@
("catalog_source", "sources", "expectation"),
[
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1": {
Expand Down Expand Up @@ -74,7 +74,7 @@
does_not_raise(),
),
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1": {
Expand Down
24 changes: 12 additions & 12 deletions tests/unit/checks/catalog/test_columns.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning)
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import CatalogTable
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import Nodes as CatalogNodes


from dbt_bouncer.artifact_parsers.dbt_cloud.manifest_latest import Nodes4, Nodes6
Expand Down Expand Up @@ -34,7 +34,7 @@
("catalog_node", "models", "expectation"),
[
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1": {
Expand Down Expand Up @@ -90,7 +90,7 @@
does_not_raise(),
),
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1": {
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_check_column_description_populated(catalog_node, models, expectation):
("catalog_node", "column_name_pattern", "test_name", "tests", "expectation"),
[
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1": {
Expand Down Expand Up @@ -208,7 +208,7 @@ def test_check_column_description_populated(catalog_node, models, expectation):
does_not_raise(),
),
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1": {
Expand Down Expand Up @@ -279,7 +279,7 @@ def test_check_column_has_specified_test(
("catalog_node", "models", "expectation"),
[
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1": {
Expand Down Expand Up @@ -333,7 +333,7 @@ def test_check_column_has_specified_test(
does_not_raise(),
),
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1": {
Expand Down Expand Up @@ -396,7 +396,7 @@ def test_check_columns_are_all_documented(catalog_node, models, expectation):
("catalog_node", "models", "expectation"),
[
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1": {
Expand Down Expand Up @@ -442,7 +442,7 @@ def test_check_columns_are_all_documented(catalog_node, models, expectation):
does_not_raise(),
),
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1": {
Expand Down Expand Up @@ -517,7 +517,7 @@ def test_check_columns_are_documented_in_public_models(
("catalog_node", "column_name_pattern", "types", "expectation"),
[
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1_date": {
Expand All @@ -540,7 +540,7 @@ def test_check_columns_are_documented_in_public_models(
does_not_raise(),
),
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1_date": {
Expand Down Expand Up @@ -573,7 +573,7 @@ def test_check_columns_are_documented_in_public_models(
does_not_raise(),
),
(
CatalogTable(
CatalogNodes(
**{
"columns": {
"col_1": {
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/test_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=UserWarning)
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import (
CatalogTable, # noqa: F401
Nodes as CatalogNodes, # noqa: F401
)
from unittest.mock import MagicMock

Expand Down Expand Up @@ -55,7 +55,7 @@ def test_runner_coverage(caplog, tmp_path):
warnings.filterwarnings("ignore", category=UserWarning)
from dbt_artifacts_parser.parser import parse_manifest
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import (
CatalogTable, # noqa: F401
Nodes as CatalogNodes, # noqa: F401
)
from dbt_bouncer.artifact_parsers.dbt_cloud.manifest_latest import ( # noqa: F401
Exposures,
Expand Down Expand Up @@ -189,7 +189,7 @@ def test_runner_failure():
warnings.filterwarnings("ignore", category=UserWarning)
from dbt_artifacts_parser.parser import parse_manifest
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import (
CatalogTable, # noqa: F401
Nodes as CatalogNodes, # noqa: F401
)
from dbt_bouncer.artifact_parsers.dbt_cloud.manifest_latest import ( # noqa: F401
Exposures,
Expand Down Expand Up @@ -315,7 +315,7 @@ def test_runner_success():
warnings.filterwarnings("ignore", category=UserWarning)
from dbt_artifacts_parser.parser import parse_manifest
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import (
CatalogTable, # noqa: F401
Nodes as CatalogNodes, # noqa: F401
)
from dbt_bouncer.artifact_parsers.dbt_cloud.manifest_latest import ( # noqa: F401
Exposures,
Expand Down Expand Up @@ -440,7 +440,7 @@ def test_runner_windows(caplog, tmp_path):
warnings.filterwarnings("ignore", category=UserWarning)
from dbt_artifacts_parser.parser import parse_manifest
from dbt_artifacts_parser.parsers.catalog.catalog_v1 import (
CatalogTable, # noqa: F401
Nodes as CatalogNodes, # noqa: F401
)

DbtBouncerConf.model_rebuild()
Expand Down

0 comments on commit 68b9f10

Please sign in to comment.