-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor EventManager setup and interaction (#9180)
* moving types_pb2.py to common/events * move event manager setup back to core, remove ref to global EVENT_MANAGER and clean up event manager functions * move invocation_id from events to first class common concept * move lowercase utils to common * move lowercase utils to common * ref CAPTURE_STREAM through method * add changie
- Loading branch information
1 parent
373125e
commit 41ac915
Showing
26 changed files
with
241 additions
and
185 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
kind: Breaking Changes | ||
body: move event manager setup back to core, remove ref to global EVENT_MANAGER and | ||
clean up event manager functions | ||
time: 2023-11-30T13:53:48.645192-08:00 | ||
custom: | ||
Author: colin-rogers-dbt | ||
Issue: "9150" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Under the Hood | ||
body: Move lowercase utils method to common | ||
time: 2023-11-30T13:54:32.561673-08:00 | ||
custom: | ||
Author: colin-rogers-dbt | ||
Issue: "9180" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from dbt.common.events.base_types import EventLevel | ||
from dbt.common.events.event_manager_client import get_event_manager | ||
from dbt.common.events.functions import get_stdout_config | ||
from dbt.common.events.logger import LineFormat | ||
|
||
# make sure event manager starts with a logger | ||
get_event_manager().add_logger( | ||
get_stdout_config(LineFormat.PlainText, True, EventLevel.INFO, False) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Since dbt-rpc does not do its own log setup, and since some events can | ||
# currently fire before logs can be configured by setup_event_logger(), we | ||
# create a default configuration with default settings and no file output. | ||
from dbt.common.events.event_manager import IEventManager, EventManager | ||
|
||
_EVENT_MANAGER: IEventManager = EventManager() | ||
|
||
|
||
def get_event_manager() -> IEventManager: | ||
global _EVENT_MANAGER | ||
return _EVENT_MANAGER | ||
|
||
|
||
def add_logger_to_manager(logger) -> None: | ||
global _EVENT_MANAGER | ||
_EVENT_MANAGER.add_logger(logger) | ||
|
||
|
||
def ctx_set_event_manager(event_manager: IEventManager) -> None: | ||
global _EVENT_MANAGER | ||
_EVENT_MANAGER = event_manager | ||
|
||
|
||
def cleanup_event_logger() -> None: | ||
# Reset to a no-op manager to release streams associated with logs. This is | ||
# especially important for tests, since pytest replaces the stdout stream | ||
# during test runs, and closes the stream after the test is over. | ||
_EVENT_MANAGER.loggers.clear() | ||
_EVENT_MANAGER.callbacks.clear() |
Oops, something went wrong.