From f88c0414d42129736bead9fbe7d425d4b3040980 Mon Sep 17 00:00:00 2001 From: Leo Schick Date: Tue, 7 Nov 2023 13:24:23 +0100 Subject: [PATCH] add flag --no-skip-on-failture for command build, run, retry, seed --- .changes/unreleased/Features-20231107-132842.yaml | 6 ++++++ core/dbt/cli/main.py | 4 ++++ core/dbt/cli/params.py | 7 +++++++ core/dbt/flags.py | 1 + core/dbt/task/runnable.py | 6 ++++-- core/dbt/utils.py | 1 + 6 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .changes/unreleased/Features-20231107-132842.yaml diff --git a/.changes/unreleased/Features-20231107-132842.yaml b/.changes/unreleased/Features-20231107-132842.yaml new file mode 100644 index 00000000000..a29049457e4 --- /dev/null +++ b/.changes/unreleased/Features-20231107-132842.yaml @@ -0,0 +1,6 @@ +kind: Features +body: add flag --no-skip-on-failture +time: 2023-11-07T13:28:42.420727773+01:00 +custom: + Author: leo-schick + Issue: "2142" diff --git a/core/dbt/cli/main.py b/core/dbt/cli/main.py index 7d4560a7910..dcf0aa2ad12 100644 --- a/core/dbt/cli/main.py +++ b/core/dbt/cli/main.py @@ -188,6 +188,7 @@ def cli(ctx, **kwargs): @p.full_refresh @p.include_saved_query @p.indirect_selection +@p.no_skip_on_failture @p.profile @p.profiles_dir @p.project_dir @@ -596,6 +597,7 @@ def parse(ctx, **kwargs): @p.deprecated_favor_state @p.exclude @p.full_refresh +@p.no_skip_on_failture @p.profile @p.profiles_dir @p.project_dir @@ -634,6 +636,7 @@ def run(ctx, **kwargs): @p.project_dir @p.profiles_dir @p.vars +@p.no_skip_on_failture @p.profile @p.target @p.state @@ -732,6 +735,7 @@ def run_operation(ctx, **kwargs): @global_flags @p.exclude @p.full_refresh +@p.no_skip_on_failture @p.profile @p.profiles_dir @p.project_dir diff --git a/core/dbt/cli/params.py b/core/dbt/cli/params.py index 1898815a724..0fff1632616 100644 --- a/core/dbt/cli/params.py +++ b/core/dbt/cli/params.py @@ -113,6 +113,13 @@ help="Stop execution on first failure.", ) +no_skip_on_failture = click.option( + "--no-skip-on-failture", + envvar="DBT_NO_SKIP_ON_FAILTURE", + help="If specified, dbt will proceed with downstream models even the dependent model failed.", + is_flag=True, +) + favor_state = click.option( "--favor-state/--no-favor-state", envvar="DBT_FAVOR_STATE", diff --git a/core/dbt/flags.py b/core/dbt/flags.py index 891d510f2e1..7467a7fb700 100644 --- a/core/dbt/flags.py +++ b/core/dbt/flags.py @@ -77,6 +77,7 @@ def get_flag_dict(): "log_format", "version_check", "fail_fast", + "no_skip_on_failture", "send_anonymous_usage_stats", "printer_width", "indirect_selection", diff --git a/core/dbt/task/runnable.py b/core/dbt/task/runnable.py index a5c3a5153bd..294efb13a74 100644 --- a/core/dbt/task/runnable.py +++ b/core/dbt/task/runnable.py @@ -396,8 +396,10 @@ def _mark_dependent_errors( ) -> None: if self.graph is None: raise DbtInternalError("graph is None in _mark_dependent_errors") - for dep_node_id in self.graph.get_dependent_nodes(UniqueId(node_id)): - self._skipped_children[dep_node_id] = cause + no_skip_on_failture = get_flags().NO_SKIP_ON_FAILTURE + if not no_skip_on_failture: + for dep_node_id in self.graph.get_dependent_nodes(UniqueId(node_id)): + self._skipped_children[dep_node_id] = cause def populate_adapter_cache( self, adapter, required_schemas: Optional[Set[BaseRelation]] = None diff --git a/core/dbt/utils.py b/core/dbt/utils.py index 2386d226aab..12a7514fe9b 100644 --- a/core/dbt/utils.py +++ b/core/dbt/utils.py @@ -649,6 +649,7 @@ def args_to_dict(args): "debug", "full_refresh", "fail_fast", + "no_skip_on_failture", "warn_error", "single_threaded", "log_cache_events",