Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
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__ = "3.0.2"
__version__ = "3.0.3"
27 changes: 26 additions & 1 deletion airflow_dbt_python/hooks/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

from __future__ import annotations

import base64
import binascii
import json
import operator
import re
Expand All @@ -26,6 +28,24 @@
from airflow.models.connection import Connection


def try_decode_base64(s: str) -> str:
"""Attempt to decode a string from base64.

If the string is not valid base64, returns the original value.

Args:
s: The string to decode.

Returns:
The decoded string, or the original value if decoding fails.
"""
try:
s = base64.b64decode(s, validate=True).decode("utf-8")
except binascii.Error:
pass
return s
Comment on lines +31 to +46
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!



class DbtConnectionParam(NamedTuple):
"""A tuple indicating connection parameters relevant to dbt.

Expand All @@ -40,6 +60,7 @@ class DbtConnectionParam(NamedTuple):
name: str
store_override_name: Optional[str] = None
default: Optional[Any] = None
converter: Callable[[Any], Any] | None = None

@property
def override_name(self):
Expand Down Expand Up @@ -230,6 +251,8 @@ def get_dbt_details_from_connection(self, conn: Connection) -> dict[str, Any]:
if isinstance(param, DbtConnectionParam):
key = param.override_name
value = getattr(conn, param.name, param.default)
if param.converter:
value = param.converter(value)
elif isinstance(param, DbtConnectionConditionParam):
key, default = param.resolve(conn)
value = getattr(conn, param.name, default)
Expand Down Expand Up @@ -399,7 +422,9 @@ class DbtSnowflakeHook(DbtConnectionHook):
"database",
DbtConnectionParam("refresh_token", "token"),
DbtConnectionParam("private_key_file", "private_key_path"),
DbtConnectionParam("private_key_content", "private_key"),
DbtConnectionParam(
"private_key_content", "private_key", converter=try_decode_base64
),
]


Expand Down
8 changes: 6 additions & 2 deletions airflow_dbt_python/utils/configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,14 +181,18 @@ class BaseConfig:

# legacy behaviors - https://github.com/dbt-labs/dbt-core/blob/main/docs/guides/behavior-change-flags.md
require_batched_execution_for_custom_microbatch_strategy: bool = False
require_event_names_in_deprecations: bool = False
require_explicit_package_overrides_for_builtin_materializations: bool = True
require_resource_names_without_spaces: bool = False
source_freshness_run_project_hooks: bool = False
require_resource_names_without_spaces: bool = True
source_freshness_run_project_hooks: bool = True
skip_nodes_if_on_run_start_fails: bool = False
state_modified_compare_more_unrendered_values: bool = False
state_modified_compare_vars: bool = False
require_yaml_configuration_for_mf_time_spines: bool = False
require_nested_cumulative_type_params: bool = False
validate_macro_args: bool = False
require_all_warnings_handled_by_warn_error: bool = False
require_generic_test_arguments_property: bool = False

def __post_init__(self):
"""Post initialization actions for a dbt configuration."""
Expand Down
22 changes: 1 addition & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "airflow-dbt-python"
version = "3.0.2"
version = "3.0.3"
description = "A collection of Airflow operators, hooks, and utilities to execute dbt commands"
authors = [{ name = "Tomás Farías Santana", email = "[email protected]" }]
license = "MIT"
Expand Down Expand Up @@ -71,7 +71,6 @@ dev = [
"apache-airflow-providers-amazon>=3.0.0",
"apache-airflow-providers-google>=11.0.0",
"apache-airflow-providers-ssh>=3.0.0",
"black>=22",
"boto3-stubs[s3]>=1.26.8",
"coverage[toml]>=7.2",
# docutils 0.21 causes an error with poetry (https://github.com/python-poetry/poetry/issues/9293)
Expand All @@ -97,25 +96,6 @@ docs = [
"zipp>=3.19.1",
]

[tool.black]
line-length = 88
target-version = ["py39", "py310", "py311", "py312"]
include = '\.pyi?$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
'''
Comment on lines -100 to -117
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for removing this


[tool.coverage.run]
source = ["airflow_dbt_python"]

Expand Down
Loading
Loading