-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
Copy pathmain.py
1169 lines (1029 loc) · 33 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from typing import List
from dbt.logger import log_cache_events, log_manager
import argparse
import os.path
import sys
import traceback
from contextlib import contextmanager
from pathlib import Path
import dbt.version
from dbt.events.functions import fire_event, setup_event_logger
from dbt.events.types import (
MainEncounteredError, MainKeyboardInterrupt, MainReportVersion, MainReportArgs,
MainTrackingUserState, MainStackTrace
)
import dbt.flags as flags
import dbt.task.build as build_task
import dbt.task.clean as clean_task
import dbt.task.compile as compile_task
import dbt.task.debug as debug_task
import dbt.task.deps as deps_task
import dbt.task.freshness as freshness_task
import dbt.task.generate as generate_task
import dbt.task.init as init_task
import dbt.task.list as list_task
import dbt.task.parse as parse_task
import dbt.task.run as run_task
import dbt.task.run_operation as run_operation_task
import dbt.task.seed as seed_task
import dbt.task.serve as serve_task
import dbt.task.snapshot as snapshot_task
import dbt.task.test as test_task
from dbt.profiler import profiler
from dbt.adapters.factory import reset_adapters, cleanup_connections
import dbt.tracking
from dbt.utils import ExitCodes, args_to_dict
from dbt.config.profile import DEFAULT_PROFILES_DIR, read_user_config
from dbt.exceptions import (
InternalException,
NotImplementedException,
FailedToConnectException
)
class DBTVersion(argparse.Action):
"""This is very very similar to the builtin argparse._Version action,
except it just calls dbt.version.get_version_information().
"""
def __init__(self,
option_strings,
version=None,
dest=argparse.SUPPRESS,
default=argparse.SUPPRESS,
help="show program's version number and exit"):
super().__init__(
option_strings=option_strings,
dest=dest,
default=default,
nargs=0,
help=help)
def __call__(self, parser, namespace, values, option_string=None):
formatter = argparse.RawTextHelpFormatter(prog=parser.prog)
formatter.add_text(dbt.version.get_version_information())
parser.exit(message=formatter.format_help())
class DBTArgumentParser(argparse.ArgumentParser):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.register('action', 'dbtversion', DBTVersion)
def add_optional_argument_inverse(
self,
name,
*,
enable_help=None,
disable_help=None,
dest=None,
no_name=None,
default=None,
):
mutex_group = self.add_mutually_exclusive_group()
if not name.startswith('--'):
raise InternalException(
'cannot handle optional argument without "--" prefix: '
f'got "{name}"'
)
if dest is None:
dest_name = name[2:].replace('-', '_')
else:
dest_name = dest
if no_name is None:
no_name = f'--no-{name[2:]}'
mutex_group.add_argument(
name,
action='store_const',
const=True,
dest=dest_name,
default=default,
help=enable_help,
)
mutex_group.add_argument(
f'--no-{name[2:]}',
action='store_const',
const=False,
dest=dest_name,
default=default,
help=disable_help,
)
return mutex_group
def main(args=None):
if args is None:
args = sys.argv[1:]
with log_manager.applicationbound():
try:
results, succeeded = handle_and_check(args)
if succeeded:
exit_code = ExitCodes.Success.value
else:
exit_code = ExitCodes.ModelError.value
except KeyboardInterrupt:
# if the logger isn't configured yet, it will use the default logger
fire_event(MainKeyboardInterrupt())
exit_code = ExitCodes.UnhandledError.value
# This can be thrown by eg. argparse
except SystemExit as e:
exit_code = e.code
except BaseException as e:
fire_event(MainEncounteredError(e=str(e)))
fire_event(MainStackTrace(stack_trace=traceback.format_exc()))
exit_code = ExitCodes.UnhandledError.value
sys.exit(exit_code)
# here for backwards compatibility
def handle(args):
res, success = handle_and_check(args)
return res
@contextmanager
def adapter_management():
reset_adapters()
try:
yield
finally:
cleanup_connections()
def handle_and_check(args):
with log_manager.applicationbound():
parsed = parse_args(args)
# Set flags from args, user config, and env vars
user_config = read_user_config(flags.PROFILES_DIR) # This is read again later
flags.set_from_args(parsed, user_config)
dbt.tracking.initialize_from_flags()
# Set log_format from flags
parsed.cls.set_log_format()
# we've parsed the args and set the flags - we can now decide if we're debug or not
if flags.DEBUG:
log_manager.set_debug()
profiler_enabled = False
if parsed.record_timing_info:
profiler_enabled = True
with profiler(
enable=profiler_enabled,
outfile=parsed.record_timing_info
):
with adapter_management():
task, res = run_from_args(parsed)
success = task.interpret_results(res)
return res, success
@contextmanager
def track_run(task):
dbt.tracking.track_invocation_start(config=task.config, args=task.args)
try:
yield
dbt.tracking.track_invocation_end(
config=task.config, args=task.args, result_type="ok"
)
except (NotImplementedException,
FailedToConnectException) as e:
fire_event(MainEncounteredError(e=str(e)))
dbt.tracking.track_invocation_end(
config=task.config, args=task.args, result_type="error"
)
except Exception:
dbt.tracking.track_invocation_end(
config=task.config, args=task.args, result_type="error"
)
raise
finally:
dbt.tracking.flush()
def run_from_args(parsed):
log_cache_events(getattr(parsed, 'log_cache_events', False))
# this will convert DbtConfigErrors into RuntimeExceptions
# task could be any one of the task objects
task = parsed.cls.from_args(args=parsed)
# Set up logging
log_path = None
if task.config is not None:
log_path = getattr(task.config, 'log_path', None)
log_manager.set_path(log_path)
# if 'list' task: set stdout to WARN instead of INFO
level_override = parsed.cls.pre_init_hook(parsed)
setup_event_logger(log_path or 'logs', level_override)
fire_event(MainReportVersion(v=str(dbt.version.installed)))
fire_event(MainReportArgs(args=args_to_dict(parsed)))
if dbt.tracking.active_user is not None: # mypy appeasement, always true
fire_event(MainTrackingUserState(user_state=dbt.tracking.active_user.state()))
results = None
with track_run(task):
results = task.run()
return task, results
def _build_base_subparser():
base_subparser = argparse.ArgumentParser(add_help=False)
base_subparser.add_argument(
'--project-dir',
default=None,
type=str,
help='''
Which directory to look in for the dbt_project.yml file.
Default is the current working directory and its parents.
'''
)
base_subparser.add_argument(
'--profiles-dir',
default=None,
dest='sub_profiles_dir', # Main cli arg precedes subcommand
type=str,
help='''
Which directory to look in for the profiles.yml file. Default = {}
'''.format(DEFAULT_PROFILES_DIR)
)
base_subparser.add_argument(
'--profile',
required=False,
type=str,
help='''
Which profile to load. Overrides setting in dbt_project.yml.
'''
)
base_subparser.add_argument(
'-t',
'--target',
default=None,
type=str,
help='''
Which target to load for the given profile
''',
)
base_subparser.add_argument(
'--vars',
type=str,
default='{}',
help='''
Supply variables to the project. This argument overrides variables
defined in your dbt_project.yml file. This argument should be a YAML
string, eg. '{my_variable: my_value}'
'''
)
# if set, log all cache events. This is extremely verbose!
base_subparser.add_argument(
'--log-cache-events',
action='store_true',
help=argparse.SUPPRESS,
)
base_subparser.set_defaults(defer=None, state=None)
return base_subparser
def _build_docs_subparser(subparsers, base_subparser):
docs_sub = subparsers.add_parser(
'docs',
help='''
Generate or serve the documentation website for your project.
'''
)
return docs_sub
def _build_source_subparser(subparsers, base_subparser):
source_sub = subparsers.add_parser(
'source',
help='''
Manage your project's sources
''',
)
return source_sub
def _build_init_subparser(subparsers, base_subparser):
sub = subparsers.add_parser(
'init',
parents=[base_subparser],
help='''
Initialize a new DBT project.
'''
)
sub.add_argument(
'project_name',
nargs='?',
help='''
Name of the new DBT project.
'''
)
sub.add_argument(
'-s',
'--skip-profile-setup',
dest='skip_profile_setup',
action='store_true',
help='''
Skip interative profile setup.
'''
)
sub.set_defaults(cls=init_task.InitTask, which='init', rpc_method=None)
return sub
def _build_build_subparser(subparsers, base_subparser):
sub = subparsers.add_parser(
'build',
parents=[base_subparser],
help='''
Run all Seeds, Models, Snapshots, and tests in DAG order
'''
)
sub.set_defaults(
cls=build_task.BuildTask,
which='build',
rpc_method='build'
)
sub.add_argument(
'-x',
'--fail-fast',
dest='sub_fail_fast',
action='store_true',
help='''
Stop execution upon a first failure.
'''
)
sub.add_argument(
'--store-failures',
action='store_true',
help='''
Store test results (failing rows) in the database
'''
)
sub.add_argument(
'--indirect-selection',
choices=['eager', 'cautious'],
default='eager',
dest='indirect_selection',
help='''
Select all tests that are adjacent to selected resources,
even if they those resources have been explicitly selected.
''',
)
resource_values: List[str] = [
str(s) for s in build_task.BuildTask.ALL_RESOURCE_VALUES
] + ['all']
sub.add_argument('--resource-type',
choices=resource_values,
action='append',
default=[],
dest='resource_types')
# explicity don't support --models
sub.add_argument(
'-s',
'--select',
dest='select',
nargs='+',
help='''
Specify the nodes to include.
''',
)
_add_common_selector_arguments(sub)
return sub
def _build_clean_subparser(subparsers, base_subparser):
sub = subparsers.add_parser(
'clean',
parents=[base_subparser],
help='''
Delete all folders in the clean-targets list
(usually the dbt_packages and target directories.)
'''
)
sub.set_defaults(cls=clean_task.CleanTask, which='clean', rpc_method=None)
return sub
def _build_debug_subparser(subparsers, base_subparser):
sub = subparsers.add_parser(
'debug',
parents=[base_subparser],
help='''
Show some helpful information about dbt for debugging.
Not to be confused with the --debug option which increases verbosity.
'''
)
sub.add_argument(
'--config-dir',
action='store_true',
help='''
If specified, DBT will show path information for this project
'''
)
_add_version_check(sub)
sub.set_defaults(cls=debug_task.DebugTask, which='debug', rpc_method=None)
return sub
def _build_deps_subparser(subparsers, base_subparser):
sub = subparsers.add_parser(
'deps',
parents=[base_subparser],
help='''
Pull the most recent version of the dependencies listed in packages.yml
'''
)
sub.set_defaults(cls=deps_task.DepsTask, which='deps', rpc_method='deps')
return sub
def _build_snapshot_subparser(subparsers, base_subparser):
sub = subparsers.add_parser(
'snapshot',
parents=[base_subparser],
help='''
Execute snapshots defined in your project
''',
)
sub.add_argument(
'--threads',
type=int,
required=False,
help='''
Specify number of threads to use while snapshotting tables.
Overrides settings in profiles.yml.
'''
)
sub.set_defaults(cls=snapshot_task.SnapshotTask, which='snapshot',
rpc_method='snapshot')
return sub
def _add_defer_argument(*subparsers):
for sub in subparsers:
sub.add_optional_argument_inverse(
'--defer',
enable_help='''
If set, defer to the state variable for resolving unselected nodes.
''',
disable_help='''
If set, do not defer to the state variable for resolving unselected
nodes.
''',
default=flags.DEFER_MODE,
)
def _build_run_subparser(subparsers, base_subparser):
run_sub = subparsers.add_parser(
'run',
parents=[base_subparser],
help='''
Compile SQL and execute against the current target database.
'''
)
run_sub.add_argument(
'-x',
'--fail-fast',
dest='sub_fail_fast',
action='store_true',
help='''
Stop execution upon a first failure.
'''
)
run_sub.set_defaults(cls=run_task.RunTask, which='run', rpc_method='run')
return run_sub
def _build_compile_subparser(subparsers, base_subparser):
sub = subparsers.add_parser(
'compile',
parents=[base_subparser],
help='''
Generates executable SQL from source, model, test, and analysis files.
Compiled SQL files are written to the target/ directory.
'''
)
sub.set_defaults(cls=compile_task.CompileTask, which='compile',
rpc_method='compile')
sub.add_argument('--parse-only', action='store_true')
return sub
def _build_parse_subparser(subparsers, base_subparser):
sub = subparsers.add_parser(
'parse',
parents=[base_subparser],
help='''
Parsed the project and provides information on performance
'''
)
sub.set_defaults(cls=parse_task.ParseTask, which='parse',
rpc_method='parse')
sub.add_argument('--write-manifest', action='store_true')
sub.add_argument('--compile', action='store_true')
return sub
def _build_docs_generate_subparser(subparsers, base_subparser):
# it might look like docs_sub is the correct parents entry, but that
# will cause weird errors about 'conflicting option strings'.
generate_sub = subparsers.add_parser('generate', parents=[base_subparser])
generate_sub.set_defaults(cls=generate_task.GenerateTask,
which='generate', rpc_method='docs.generate')
generate_sub.add_argument(
'--no-compile',
action='store_false',
dest='compile',
help='''
Do not run "dbt compile" as part of docs generation
''',
)
return generate_sub
def _add_common_selector_arguments(sub):
sub.add_argument(
'--exclude',
required=False,
nargs='+',
help='''
Specify the models to exclude.
''',
)
sub.add_argument(
'--selector',
dest='selector_name',
metavar='SELECTOR_NAME',
help='''
The selector name to use, as defined in selectors.yml
'''
)
sub.add_argument(
'--state',
help='''
If set, use the given directory as the source for json files to
compare with this project.
''',
type=Path,
default=flags.ARTIFACT_STATE_PATH,
)
def _add_selection_arguments(*subparsers):
for sub in subparsers:
sub.add_argument(
'-m',
'--models',
dest='select',
nargs='+',
help='''
Specify the nodes to include.
''',
)
sub.add_argument(
'-s',
'--select',
dest='select',
nargs='+',
help='''
Specify the nodes to include.
''',
)
_add_common_selector_arguments(sub)
def _add_table_mutability_arguments(*subparsers):
for sub in subparsers:
sub.add_argument(
'--full-refresh',
action='store_true',
help='''
If specified, dbt will drop incremental models and
fully-recalculate the incremental table from the model definition.
'''
)
def _add_version_check(sub):
sub.add_argument(
'--no-version-check',
dest='sub_version_check', # main cli arg precedes subcommands
action='store_false',
default=None,
help='''
If set, skip ensuring dbt's version matches the one specified in
the dbt_project.yml file ('require-dbt-version')
'''
)
def _add_common_arguments(*subparsers):
for sub in subparsers:
sub.add_argument(
'--threads',
type=int,
required=False,
help='''
Specify number of threads to use while executing models. Overrides
settings in profiles.yml.
'''
)
_add_version_check(sub)
def _build_seed_subparser(subparsers, base_subparser):
seed_sub = subparsers.add_parser(
'seed',
parents=[base_subparser],
help='''
Load data from csv files into your data warehouse.
''',
)
seed_sub.add_argument(
'--full-refresh',
action='store_true',
help='''
Drop existing seed tables and recreate them
''',
)
seed_sub.add_argument(
'--show',
action='store_true',
help='''
Show a sample of the loaded data in the terminal
'''
)
seed_sub.set_defaults(cls=seed_task.SeedTask, which='seed',
rpc_method='seed')
return seed_sub
def _build_docs_serve_subparser(subparsers, base_subparser):
serve_sub = subparsers.add_parser('serve', parents=[base_subparser])
serve_sub.add_argument(
'--port',
default=8080,
type=int,
help='''
Specify the port number for the docs server.
'''
)
serve_sub.add_argument(
'--no-browser',
dest='open_browser',
action='store_false',
)
serve_sub.set_defaults(cls=serve_task.ServeTask, which='serve',
rpc_method=None)
return serve_sub
def _build_test_subparser(subparsers, base_subparser):
sub = subparsers.add_parser(
'test',
parents=[base_subparser],
help='''
Runs tests on data in deployed models. Run this after `dbt run`
'''
)
sub.add_argument(
'-x',
'--fail-fast',
dest='sub_fail_fast',
action='store_true',
help='''
Stop execution upon a first test failure.
'''
)
sub.add_argument(
'--store-failures',
action='store_true',
help='''
Store test results (failing rows) in the database
'''
)
sub.add_argument(
'--indirect-selection',
choices=['eager', 'cautious'],
default='eager',
dest='indirect_selection',
help='''
Select all tests that are adjacent to selected resources,
even if they those resources have been explicitly selected.
''',
)
sub.set_defaults(cls=test_task.TestTask, which='test', rpc_method='test')
return sub
def _build_source_freshness_subparser(subparsers, base_subparser):
sub = subparsers.add_parser(
'freshness',
parents=[base_subparser],
help='''
Snapshots the current freshness of the project's sources
''',
aliases=['snapshot-freshness'],
)
sub.add_argument(
'-o',
'--output',
required=False,
help='''
Specify the output path for the json report. By default, outputs to
target/sources.json
'''
)
sub.add_argument(
'--threads',
type=int,
required=False,
help='''
Specify number of threads to use. Overrides settings in profiles.yml
'''
)
sub.set_defaults(
cls=freshness_task.FreshnessTask,
which='source-freshness',
rpc_method='source-freshness',
)
sub.add_argument(
'-s',
'--select',
dest='select',
nargs='+',
help='''
Specify the nodes to include.
''',
)
_add_common_selector_arguments(sub)
return sub
def _build_list_subparser(subparsers, base_subparser):
sub = subparsers.add_parser(
'list',
parents=[base_subparser],
help='''
List the resources in your project
''',
aliases=['ls'],
)
sub.set_defaults(cls=list_task.ListTask, which='list', rpc_method=None)
resource_values: List[str] = [
str(s) for s in list_task.ListTask.ALL_RESOURCE_VALUES
] + ['default', 'all']
sub.add_argument('--resource-type',
choices=resource_values,
action='append',
default=[],
dest='resource_types')
sub.add_argument('--output',
choices=['json', 'name', 'path', 'selector'],
default='selector')
sub.add_argument('--output-keys')
sub.add_argument(
'-m',
'--models',
dest='models',
nargs='+',
help='''
Specify the models to select and set the resource-type to 'model'.
Mutually exclusive with '--select' (or '-s') and '--resource-type'
''',
metavar='SELECTOR',
required=False,
)
sub.add_argument(
'-s',
'--select',
dest='select',
nargs='+',
help='''
Specify the nodes to include.
''',
metavar='SELECTOR',
required=False,
)
sub.add_argument(
'--indirect-selection',
choices=['eager', 'cautious'],
default='eager',
dest='indirect_selection',
help='''
Select all tests that are adjacent to selected resources,
even if they those resources have been explicitly selected.
''',
)
_add_common_selector_arguments(sub)
return sub
def _build_run_operation_subparser(subparsers, base_subparser):
sub = subparsers.add_parser(
'run-operation',
parents=[base_subparser],
help='''
Run the named macro with any supplied arguments.
'''
)
sub.add_argument(
'macro',
help='''
Specify the macro to invoke. dbt will call this macro with the supplied
arguments and then exit
''',
)
sub.add_argument(
'--args',
type=str,
default='{}',
help='''
Supply arguments to the macro. This dictionary will be mapped to the
keyword arguments defined in the selected macro. This argument should
be a YAML string, eg. '{my_variable: my_value}'
'''
)
sub.set_defaults(cls=run_operation_task.RunOperationTask,
which='run-operation', rpc_method='run-operation')
return sub
def parse_args(args, cls=DBTArgumentParser):
p = cls(
prog='dbt',
description='''
An ELT tool for managing your SQL transformations and data models.
For more documentation on these commands, visit: docs.getdbt.com
''',
epilog='''
Specify one of these sub-commands and you can find more help from
there.
'''
)
p.add_argument(
'--version',
action='dbtversion',
help='''
Show version information
''')
p.add_argument(
'-r',
'--record-timing-info',
default=None,
type=str,
help='''
When this option is passed, dbt will output low-level timing stats to
the specified file. Example: `--record-timing-info output.profile`
'''
)
p.add_argument(
'-d',
'--debug',
action='store_true',
default=None,
help='''
Display debug logging during dbt execution. Useful for debugging and
making bug reports.
'''
)
p.add_argument(
'--log-format',
choices=['text', 'json', 'default'],
default=None,
help='''Specify the log format, overriding the command's default.'''
)
p.add_argument(
'--no-write-json',
action='store_false',
default=None,
dest='write_json',
help='''
If set, skip writing the manifest and run_results.json files to disk
'''
)
colors_flag = p.add_mutually_exclusive_group()
colors_flag.add_argument(
'--use-colors',
action='store_const',
const=True,
default=None,
dest='use_colors',
help='''
Colorize the output DBT prints to the terminal. Output is colorized by
default and may also be set in a profile or at the command line.
Mutually exclusive with --no-use-colors
'''
)
colors_flag.add_argument(
'--no-use-colors',
action='store_const',
const=False,
dest='use_colors',
help='''
Do not colorize the output DBT prints to the terminal. Output is
colorized by default and may also be set in a profile or at the
command line.
Mutually exclusive with --use-colors
'''
)
p.add_argument(
'--printer-width',
dest='printer_width',
help='''
Sets the width of terminal output
'''
)
p.add_argument(
'--warn-error',
action='store_true',
default=None,
help='''
If dbt would normally warn, instead raise an exception. Examples
include --models that selects nothing, deprecations, configurations
with no associated models, invalid test configurations, and missing
sources/refs in tests.
'''
)
p.add_argument(
'--no-version-check',
dest='version_check',
action='store_false',
default=None,
help='''
If set, skip ensuring dbt's version matches the one specified in
the dbt_project.yml file ('require-dbt-version')
'''