Skip to content

Commit

Permalink
Fix #8682: Override path-like args in dbt retry (#8803)
Browse files Browse the repository at this point in the history
  • Loading branch information
aranke authored Oct 10, 2023
1 parent 6461f5a commit 3f7f7de
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20231010-182801.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Override path-like args in dbt retry
time: 2023-10-10T18:28:01.556443+01:00
custom:
Author: aranke
Issue: "8682"
18 changes: 17 additions & 1 deletion core/dbt/task/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@
from dbt.task.test import TestTask

RETRYABLE_STATUSES = {NodeStatus.Error, NodeStatus.Fail, NodeStatus.Skipped, NodeStatus.RuntimeErr}
OVERRIDE_PARENT_FLAGS = {
"log_path",
"output_path",
"profiles_dir",
"profiles_dir_exists_false",
"project_dir",
"defer_state",
"deprecated_state",
"target_path",
}

TASK_DICT = {
"build": BuildTask,
Expand Down Expand Up @@ -91,7 +101,13 @@ def run(self):
if k in self.previous_args and v(self.previous_args[k]):
del self.previous_args[k]

retry_flags = Flags.from_dict(cli_command, self.previous_args)
previous_args = {
k: v for k, v in self.previous_args.items() if k not in OVERRIDE_PARENT_FLAGS
}
current_args = {k: v for k, v in self.args.__dict__.items() if k in OVERRIDE_PARENT_FLAGS}
combined_args = {**previous_args, **current_args}

retry_flags = Flags.from_dict(cli_command, combined_args)
retry_config = RuntimeConfig.from_args(args=retry_flags)

class TaskWrapper(self.task_class):
Expand Down
20 changes: 20 additions & 0 deletions tests/functional/retry/test_retry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from shutil import copytree, move

import pytest

from dbt.contracts.results import RunStatus, TestStatus
Expand Down Expand Up @@ -271,3 +273,21 @@ def test_resource_type(self, project):
# nothing to do
results = run_dbt(["retry"])
assert len(results) == 0


class TestRetryOverridePath:
@pytest.fixture(scope="class")
def models(self):
return {
"sample_model.sql": models__sample_model,
}

def test_retry(self, project):
project_root = project.project_root
proj_location_1 = project_root / "proj_location_1"
proj_location_2 = project_root / "proj_location_2"

copytree(project_root, proj_location_1)
run_dbt(["run", "--project-dir", "proj_location_1"], expect_pass=False)
move(proj_location_1, proj_location_2)
run_dbt(["retry", "--project-dir", "proj_location_2"], expect_pass=False)

0 comments on commit 3f7f7de

Please sign in to comment.