Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #8682: Override path-like args in dbt retry #8803

Merged
merged 4 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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 = {

Check warning on line 104 in core/dbt/task/retry.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/retry.py#L104

Added line #L104 was not covered by tests
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}

Check warning on line 108 in core/dbt/task/retry.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/retry.py#L107-L108

Added lines #L107 - L108 were not covered by tests

retry_flags = Flags.from_dict(cli_command, combined_args)

Check warning on line 110 in core/dbt/task/retry.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/retry.py#L110

Added line #L110 was not covered by tests
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)
Loading