Skip to content

Commit

Permalink
Fully remove legacy logger (#9353)
Browse files Browse the repository at this point in the history
* tried blinding cutting out all logbook dependency related bits

* cleanup

* changelog

* remove import

* remove unused import
  • Loading branch information
emmyoop authored Jan 10, 2024
1 parent b12ed0f commit 51f6255
Show file tree
Hide file tree
Showing 36 changed files with 120 additions and 2,235 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"
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
1 change: 0 additions & 1 deletion core/dbt/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def global_flags(func):
@p.cache_selected_only
@p.debug
@p.deprecated_print
@p.enable_legacy_logger
@p.fail_fast
@p.log_cache_events
@p.log_file_max_bytes
Expand Down
6 changes: 0 additions & 6 deletions core/dbt/cli/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@
is_flag=True,
)

enable_legacy_logger = click.option(
"--enable-legacy-logger/--no-enable-legacy-logger",
envvar="DBT_ENABLE_LEGACY_LOGGER",
hidden=True,
)

exclude = click.option(
"--exclude",
envvar=None,
Expand Down
1 change: 0 additions & 1 deletion core/dbt/cli/requires.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import dbt.tracking
from dbt_common.invocation import reset_invocation_id
from dbt.mp_context import get_mp_context
from dbt.version import installed as installed_version
from dbt.adapters.factory import adapter_management
from dbt.flags import set_flags, get_flag_dict
Expand Down
11 changes: 4 additions & 7 deletions core/dbt/contracts/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from dbt.events.types import TimingInfoCollected
from dbt_common.events.contextvars import get_node_info
from dbt_common.events.helpers import datetime_to_json_string
from dbt.logger import TimingProcessor
from dbt_common.utils.formatting import lowercase
from dbt_common.utils import cast_to_str, cast_to_int
from dbt_common.dataclass_schema import dbtClassMixin, StrEnum
Expand Down Expand Up @@ -73,13 +72,11 @@ def __enter__(self):
def __exit__(self, exc_type, exc_value, traceback):
self.timing_info.end()
self.callback(self.timing_info)
# Note: when legacy logger is removed, we can remove the following line
with TimingProcessor(self.timing_info):
fire_event(
TimingInfoCollected(
timing_info=self.timing_info.to_msg_dict(), node_info=get_node_info()
)
fire_event(
TimingInfoCollected(
timing_info=self.timing_info.to_msg_dict(), node_info=get_node_info()
)
)


class RunningStatus(StrEnum):
Expand Down
12 changes: 2 additions & 10 deletions core/dbt/contracts/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
RunExecutionResult,
)
from dbt.contracts.util import VersionedSchema, schema_version
from dbt.logger import LogMessage


TaskTags = Optional[Dict[str, Any]]
Expand All @@ -24,12 +23,7 @@


@dataclass
class RemoteResult(VersionedSchema):
logs: List[LogMessage]


@dataclass
class RemoteCompileResultMixin(RemoteResult):
class RemoteCompileResultMixin(VersionedSchema):

Check warning on line 26 in core/dbt/contracts/sql.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/contracts/sql.py#L26

Added line #L26 was not covered by tests
raw_code: str
compiled_code: str
node: ResultNode
Expand All @@ -48,7 +42,7 @@ def error(self):

@dataclass
@schema_version("remote-execution-result", 1)
class RemoteExecutionResult(ExecutionResult, RemoteResult):
class RemoteExecutionResult(ExecutionResult):

Check warning on line 45 in core/dbt/contracts/sql.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/contracts/sql.py#L45

Added line #L45 was not covered by tests
results: Sequence[RunResult]
args: Dict[str, Any] = field(default_factory=dict)
generated_at: datetime = field(default_factory=datetime.utcnow)
Expand All @@ -66,14 +60,12 @@ def write(self, path: str):
def from_local_result(
cls,
base: RunExecutionResult,
logs: List[LogMessage],
) -> "RemoteExecutionResult":
return cls(
generated_at=base.generated_at,
results=base.results,
elapsed_time=base.elapsed_time,
args=base.args,
logs=logs,
)


Expand Down
18 changes: 0 additions & 18 deletions core/dbt/flags.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
# Do not import the os package because we expose this package in jinja
from os import getenv as os_getenv
from argparse import Namespace
from typing import Optional
from pathlib import Path


# for setting up logger for legacy logger
def env_set_truthy(key: str) -> Optional[str]:
"""Return the value if it was set to a "truthy" string value or None
otherwise.
"""
value = os_getenv(key)
if not value or value.lower() in ("0", "false", "f"):
return None
return value


# for setting up logger for legacy logger
ENABLE_LEGACY_LOGGER = env_set_truthy("DBT_ENABLE_LEGACY_LOGGER")


# this roughly follows the patten of EVENT_MANAGER in dbt/common/events/functions.py
# During de-globlization, we'll need to handle both similarly
# Match USE_COLORS default with default in dbt.cli.params.use_colors for use in --version
Expand Down
Loading

0 comments on commit 51f6255

Please sign in to comment.