Skip to content

Commit

Permalink
Merge branch 'main' into batch-metadata-freshness
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk authored Apr 5, 2024
2 parents f3dcac2 + 7392deb commit ebee880
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240329-093307.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Add the option to set the log level of the AdapterRegistered event
time: 2024-03-29T09:33:07.737464-05:00
custom:
Author: emmyoop
Issue: "141"
3 changes: 2 additions & 1 deletion dbt/adapters/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from dbt.adapters.events.base_types import (
DebugLevel,
DynamicLevel,
ErrorLevel,
InfoLevel,
WarnLevel,
Expand Down Expand Up @@ -281,7 +282,7 @@ def message(self) -> str:
# Skipping E032, E033, E034


class AdapterRegistered(InfoLevel):
class AdapterRegistered(DynamicLevel):
def code(self) -> str:
return "E034"

Expand Down
24 changes: 20 additions & 4 deletions dbt/adapters/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from typing import Any, Dict, List, Optional, Set, Type

from dbt_common.events.functions import fire_event
from dbt_common.events.base_types import EventLevel
from dbt_common.exceptions import DbtInternalError, DbtRuntimeError
from dbt_common.semver import VersionSpecifier

Expand Down Expand Up @@ -96,11 +97,22 @@ def load_plugin(self, name: str) -> Type[Credentials]:

return plugin.credentials

def register_adapter(self, config: AdapterRequiredConfig, mp_context: SpawnContext) -> None:
def register_adapter(
self,
config: AdapterRequiredConfig,
mp_context: SpawnContext,
adapter_registered_log_level: Optional[EventLevel] = EventLevel.INFO
) -> None:
adapter_name = config.credentials.type
adapter_type = self.get_adapter_class_by_name(adapter_name)
adapter_version = self._adapter_version(adapter_name)
fire_event(AdapterRegistered(adapter_name=adapter_name, adapter_version=adapter_version))
fire_event(
AdapterRegistered(
adapter_name=adapter_name,
adapter_version=adapter_version
),
level=adapter_registered_log_level
)
with self.lock:
if adapter_name in self.adapters:
# this shouldn't really happen...
Expand Down Expand Up @@ -186,8 +198,12 @@ def get_adapter_constraint_support(self, name: Optional[str]) -> List[str]:
FACTORY: AdapterContainer = AdapterContainer()


def register_adapter(config: AdapterRequiredConfig, mp_context: SpawnContext) -> None:
FACTORY.register_adapter(config, mp_context)
def register_adapter(
config: AdapterRequiredConfig,
mp_context: SpawnContext,
adapter_registered_log_level: Optional[EventLevel] = EventLevel.INFO
) -> None:
FACTORY.register_adapter(config, mp_context, adapter_registered_log_level)


def get_adapter(config: AdapterRequiredConfig):
Expand Down

0 comments on commit ebee880

Please sign in to comment.