Skip to content

Commit

Permalink
Add flag to main.py. Reinstantiate after flags (#4416) (#4419)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
  • Loading branch information
leahwicz and jtcohen6 authored Dec 3, 2021
1 parent e9f26ef commit ecf0ffe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion core/dbt/events/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
from collections import deque


# create the global event history buffer with a max size of 100k records
# create the global event history buffer with the default max size (10k)
# python 3.7 doesn't support type hints on globals, but mypy requires them. hence the ignore.
# TODO the flags module has not yet been resolved when this is created
global EVENT_HISTORY
EVENT_HISTORY = deque(maxlen=flags.EVENT_BUFFER_SIZE) # type: ignore

Expand All @@ -49,6 +50,10 @@


def setup_event_logger(log_path, level_override=None):
# flags have been resolved, and log_path is known
global EVENT_HISTORY
EVENT_HISTORY = deque(maxlen=flags.EVENT_BUFFER_SIZE) # type: ignore

make_log_dir_if_missing(log_path)
this.format_json = flags.LOG_FORMAT == 'json'
# USE_COLORS can be None if the app just started and the cli flags
Expand Down
8 changes: 8 additions & 0 deletions core/dbt/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,14 @@ def parse_args(args, cls=DBTArgumentParser):
'''
)

p.add_argument(
'--event-buffer-size',
dest='event_buffer_size',
help='''
Sets the max number of events to buffer in EVENT_HISTORY
'''
)

subs = p.add_subparsers(title="Available sub-commands")

base_subparser = _build_base_subparser()
Expand Down

0 comments on commit ecf0ffe

Please sign in to comment.