Skip to content

Commit

Permalink
replace dbt/common with dbt-common (#9342)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichelleArk authored Jan 12, 2024
1 parent cff0b65 commit 00f4a25
Show file tree
Hide file tree
Showing 269 changed files with 624 additions and 9,291 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Dependencies-20240109-120530.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Dependencies
body: Remove logbook dependency
time: 2024-01-09T12:05:30.176656-06:00
custom:
Author: emmyoop
PR: "9353"
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240110-105734.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Add dbt-common as a dependency and remove dbt/common
time: 2024-01-10T10:57:34.054908-05:00
custom:
Author: michelleark emmyoop
Issue: "9357"
2 changes: 0 additions & 2 deletions core/dbt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

### links.py

### logger.py

### main.py

### node_types.py
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/adapters/base/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
from typing import Dict, ClassVar, Any, Optional

from dbt.common.exceptions import DbtRuntimeError
from dbt_common.exceptions import DbtRuntimeError


@dataclass
Expand Down
28 changes: 14 additions & 14 deletions core/dbt/adapters/base/connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import agate

import dbt.adapters.exceptions
import dbt.common.exceptions.base
import dbt_common.exceptions.base
from dbt.adapters.contracts.connection import (
Connection,
Identifier,
Expand All @@ -38,7 +38,7 @@
MacroQueryStringSetter,
)
from dbt.adapters.events.logging import AdapterLogger
from dbt.common.events.functions import fire_event
from dbt_common.events.functions import fire_event
from dbt.adapters.events.types import (
NewConnection,
ConnectionReused,
Expand All @@ -49,8 +49,8 @@
Rollback,
RollbackFailed,
)
from dbt.common.events.contextvars import get_node_info
from dbt.common.utils import cast_to_str
from dbt_common.events.contextvars import get_node_info
from dbt_common.utils import cast_to_str

SleepTime = Union[int, float] # As taken by time.sleep.
AdapterHandle = Any # Adapter connection handle objects can be any class.
Expand Down Expand Up @@ -99,7 +99,7 @@ def get_thread_connection(self) -> Connection:
def set_thread_connection(self, conn: Connection) -> None:
key = self.get_thread_identifier()
if key in self.thread_connections:
raise dbt.common.exceptions.DbtInternalError(
raise dbt_common.exceptions.DbtInternalError(
"In set_thread_connection, existing connection exists for {}"
)
self.thread_connections[key] = conn
Expand Down Expand Up @@ -139,7 +139,7 @@ def exception_handler(self, sql: str) -> ContextManager:
:return: A context manager that handles exceptions raised by the
underlying database.
"""
raise dbt.common.exceptions.base.NotImplementedError(
raise dbt_common.exceptions.base.NotImplementedError(
"`exception_handler` is not implemented for this adapter!"
)

Expand Down Expand Up @@ -275,7 +275,7 @@ def retry_connection(
@abc.abstractmethod
def cancel_open(self) -> Optional[List[str]]:
"""Cancel all open connections on the adapter. (passable)"""
raise dbt.common.exceptions.base.NotImplementedError(
raise dbt_common.exceptions.base.NotImplementedError(
"`cancel_open` is not implemented for this adapter!"
)

Expand All @@ -290,7 +290,7 @@ def open(cls, connection: Connection) -> Connection:
This should be thread-safe, or hold the lock if necessary. The given
connection should not be in either in_use or available.
"""
raise dbt.common.exceptions.base.NotImplementedError(
raise dbt_common.exceptions.base.NotImplementedError(
"`open` is not implemented for this adapter!"
)

Expand Down Expand Up @@ -324,14 +324,14 @@ def cleanup_all(self) -> None:
@abc.abstractmethod
def begin(self) -> None:
"""Begin a transaction. (passable)"""
raise dbt.common.exceptions.base.NotImplementedError(
raise dbt_common.exceptions.base.NotImplementedError(
"`begin` is not implemented for this adapter!"
)

@abc.abstractmethod
def commit(self) -> None:
"""Commit a transaction. (passable)"""
raise dbt.common.exceptions.base.NotImplementedError(
raise dbt_common.exceptions.base.NotImplementedError(
"`commit` is not implemented for this adapter!"
)

Expand Down Expand Up @@ -369,7 +369,7 @@ def _close_handle(cls, connection: Connection) -> None:
def _rollback(cls, connection: Connection) -> None:
"""Roll back the given connection."""
if connection.transaction_open is False:
raise dbt.common.exceptions.DbtInternalError(
raise dbt_common.exceptions.DbtInternalError(
f"Tried to rollback transaction on connection "
f'"{connection.name}", but it does not have one open!'
)
Expand Down Expand Up @@ -420,7 +420,7 @@ def execute(
:return: A tuple of the query status and results (empty if fetch=False).
:rtype: Tuple[AdapterResponse, agate.Table]
"""
raise dbt.common.exceptions.base.NotImplementedError(
raise dbt_common.exceptions.base.NotImplementedError(
"`execute` is not implemented for this adapter!"
)

Expand All @@ -432,14 +432,14 @@ def add_select_query(self, sql: str) -> Tuple[Connection, Any]:
See https://github.com/dbt-labs/dbt-core/issues/8396 for more information.
"""
raise dbt.common.exceptions.base.NotImplementedError(
raise dbt_common.exceptions.base.NotImplementedError(
"`add_select_query` is not implemented for this adapter!"
)

@classmethod
def data_type_code_to_name(cls, type_code: Union[int, str]) -> str:
"""Get the string representation of the data type from the type_code."""
# https://peps.python.org/pep-0249/#type-objects
raise dbt.common.exceptions.base.NotImplementedError(
raise dbt_common.exceptions.base.NotImplementedError(
"`data_type_code_to_name` is not implemented for this adapter!"
)
12 changes: 6 additions & 6 deletions core/dbt/adapters/base/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from multiprocessing.context import SpawnContext

from dbt.adapters.capability import Capability, CapabilityDict
from dbt.common.contracts.constraints import (
from dbt_common.contracts.constraints import (
ColumnLevelConstraint,
ConstraintType,
ModelLevelConstraint,
Expand All @@ -44,7 +44,7 @@
QuoteConfigTypeError,
)

from dbt.common.exceptions import (
from dbt_common.exceptions import (
NotImplementedError,
DbtInternalError,
DbtRuntimeError,
Expand All @@ -58,15 +58,15 @@
AdapterConfig,
MacroContextGeneratorCallable,
)
from dbt.common.clients.agate_helper import (
from dbt_common.clients.agate_helper import (
empty_table,
get_column_value_uncased,
merge_tables,
table_from_rows,
Integer,
)
from dbt.common.clients.jinja import CallableMacroGenerator
from dbt.common.events.functions import fire_event, warn_or_error
from dbt_common.clients.jinja import CallableMacroGenerator
from dbt_common.events.functions import fire_event, warn_or_error
from dbt.adapters.events.types import (
CacheMiss,
ListRelations,
Expand All @@ -76,7 +76,7 @@
ConstraintNotSupported,
ConstraintNotEnforced,
)
from dbt.common.utils import filter_null_values, executor, cast_to_str, AttrDict
from dbt_common.utils import filter_null_values, executor, cast_to_str, AttrDict

from dbt.adapters.contracts.relation import RelationConfig
from dbt.adapters.base.connections import (
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/adapters/base/meta.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import abc
from functools import wraps
from typing import Callable, Optional, Any, FrozenSet, Dict, Set
from dbt.common.events.functions import warn_or_error
from dbt_common.events.functions import warn_or_error
from dbt.adapters.events.types import AdapterDeprecationWarning

Decorator = Callable[[Any], Callable]
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/adapters/base/query_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from dbt.adapters.clients.jinja import QueryStringGenerator
from dbt.adapters.contracts.connection import AdapterRequiredConfig, QueryComment
from dbt.common.exceptions import DbtRuntimeError
from dbt_common.exceptions import DbtRuntimeError


class QueryHeaderContextWrapper:
Expand Down
8 changes: 4 additions & 4 deletions core/dbt/adapters/base/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
Path,
)
from dbt.adapters.exceptions import MultipleDatabasesNotAllowedError, ApproximateMatchError
from dbt.common.utils import filter_null_values, deep_merge
from dbt_common.utils import filter_null_values, deep_merge
from dbt.adapters.utils import classproperty

import dbt.common.exceptions
import dbt_common.exceptions


Self = TypeVar("Self", bound="BaseRelation")
Expand Down Expand Up @@ -97,7 +97,7 @@ def matches(

if not search:
# nothing was passed in
raise dbt.common.exceptions.DbtRuntimeError(
raise dbt_common.exceptions.DbtRuntimeError(
"Tried to match relation, but no search path was passed!"
)

Expand Down Expand Up @@ -360,7 +360,7 @@ class InformationSchema(BaseRelation):

def __post_init__(self):
if not isinstance(self.information_schema_view, (type(None), str)):
raise dbt.common.exceptions.CompilationError(
raise dbt_common.exceptions.CompilationError(
"Got an invalid name: {}".format(self.information_schema_view)
)

Expand Down
5 changes: 3 additions & 2 deletions core/dbt/adapters/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
_make_ref_key_dict,
_ReferenceKey,
)

from dbt.adapters.exceptions.cache import (
NewNameAlreadyInCacheError,
ReferencedLinkNotCachedError,
DependentLinkNotCachedError,
TruncatedModelNameCausedCollisionError,
NoneRelationFoundError,
)
from dbt.common.events.functions import fire_event, fire_event_if
from dbt_common.events.functions import fire_event, fire_event_if
from dbt.adapters.events.types import CacheAction, CacheDumpGraph
from dbt.common.utils.formatting import lowercase
from dbt_common.utils.formatting import lowercase


def dot_separated(key: _ReferenceKey) -> str:
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/adapters/clients/jinja.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Dict, Any
from dbt.common.clients.jinja import BaseMacroGenerator, get_environment
from dbt_common.clients.jinja import BaseMacroGenerator, get_environment


class QueryStringGenerator(BaseMacroGenerator):
Expand Down
12 changes: 6 additions & 6 deletions core/dbt/adapters/contracts/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@
from mashumaro.jsonschema.annotations import Pattern

from dbt.adapters.utils import translate_aliases
from dbt.common.exceptions import DbtInternalError
from dbt.common.dataclass_schema import (
from dbt_common.exceptions import DbtInternalError
from dbt_common.dataclass_schema import (
dbtClassMixin,
StrEnum,
ExtensibleDbtClassMixin,
ValidatedStringMixin,
)
from dbt.common.contracts.util import Replaceable
from dbt.common.utils import md5
from dbt_common.contracts.util import Replaceable
from dbt_common.utils import md5

from dbt.common.events.functions import fire_event
from dbt_common.events.functions import fire_event
from dbt.adapters.events.types import NewConnectionOpening

# TODO: this is a very bad dependency - shared global state
from dbt.common.events.contextvars import get_node_info
from dbt_common.events.contextvars import get_node_info


class Identifier(ValidatedStringMixin):
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/adapters/contracts/macros.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Optional
from typing_extensions import Protocol

from dbt.common.clients.jinja import MacroProtocol
from dbt_common.clients.jinja import MacroProtocol


class MacroResolverProtocol(Protocol):
Expand Down
8 changes: 4 additions & 4 deletions core/dbt/adapters/contracts/relation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
)
from typing_extensions import Protocol

from dbt.common.dataclass_schema import dbtClassMixin, StrEnum
from dbt_common.dataclass_schema import dbtClassMixin, StrEnum

from dbt.common.contracts.util import Replaceable
from dbt.common.exceptions import CompilationError, DataclassNotDictError
from dbt.common.utils import deep_merge
from dbt_common.contracts.util import Replaceable
from dbt_common.exceptions import CompilationError, DataclassNotDictError
from dbt_common.utils import deep_merge


class RelationType(StrEnum):
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/adapters/events/base_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Aliasing common Level classes in order to make custom, but not overly-verbose versions that have PROTO_TYPES_MODULE set to the adapter-specific generated types_pb2 module
from dbt.common.events.base_types import (
from dbt_common.events.base_types import (
BaseEvent,
DynamicLevel as CommonDyanicLevel,
TestLevel as CommonTestLevel,
Expand Down
8 changes: 4 additions & 4 deletions core/dbt/adapters/events/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
AdapterEventWarning,
AdapterEventError,
)
from dbt.common.events import get_event_manager
from dbt.common.events.contextvars import get_node_info
from dbt.common.events.event_handler import set_package_logging
from dbt.common.events.functions import fire_event
from dbt_common.events import get_event_manager
from dbt_common.events.contextvars import get_node_info
from dbt_common.events.event_handler import set_package_logging
from dbt_common.events.functions import fire_event


@dataclass
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/adapters/events/types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from dbt.adapters.events.base_types import WarnLevel, InfoLevel, ErrorLevel, DebugLevel
from dbt.common.ui import line_wrap_message, warning_tag
from dbt_common.ui import line_wrap_message, warning_tag


def format_adapter_message(name, base_msg, args) -> str:
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/adapters/exceptions/alias.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Mapping, Any

from dbt.common.exceptions import DbtValidationError
from dbt_common.exceptions import DbtValidationError


class AliasError(DbtValidationError):
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/adapters/exceptions/cache.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
from typing import Dict

from dbt.common.exceptions import DbtInternalError
from dbt_common.exceptions import DbtInternalError


class CacheInconsistencyError(DbtInternalError):
Expand Down
4 changes: 2 additions & 2 deletions core/dbt/adapters/exceptions/compilation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List, Mapping, Any

from dbt.common.exceptions import CompilationError, DbtDatabaseError
from dbt.common.ui import line_wrap_message
from dbt_common.exceptions import CompilationError, DbtDatabaseError
from dbt_common.ui import line_wrap_message


class MissingConfigError(CompilationError):
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/adapters/exceptions/connection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from dbt.common.exceptions import DbtRuntimeError, DbtDatabaseError
from dbt_common.exceptions import DbtRuntimeError, DbtDatabaseError


class InvalidConnectionError(DbtRuntimeError):
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/adapters/exceptions/database.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any

from dbt.common.exceptions import NotImplementedError, CompilationError
from dbt_common.exceptions import NotImplementedError, CompilationError


class UnexpectedDbReferenceError(NotImplementedError):
Expand Down
Loading

0 comments on commit 00f4a25

Please sign in to comment.