Skip to content

Commit

Permalink
Fix #8948: Add target-path to retry (#9646)
Browse files Browse the repository at this point in the history
  • Loading branch information
aranke authored Feb 23, 2024
1 parent 7ea4670 commit d1e400e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20240223-162107.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Add target-path to retry
time: 2024-02-23T16:21:07.83639Z
custom:
Author: aranke
Issue: "8948"
1 change: 1 addition & 0 deletions core/dbt/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ def run(ctx, **kwargs):
@p.vars
@p.profile
@p.target
@p.target_path
@p.threads
@p.full_refresh
@requires.postflight
Expand Down
38 changes: 38 additions & 0 deletions tests/functional/retry/test_retry.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from pathlib import Path
from shutil import copytree, move

import pytest
Expand Down Expand Up @@ -327,3 +328,40 @@ def test_retry(self, project):
# ...and so should this one, since the effect of the full-refresh parameter should persist.
results = run_dbt(["retry"], expect_pass=False)
assert len(results) == 1


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

def test_retry_target_path_env_var(self, project, monkeypatch):
monkeypatch.setenv("DBT_TARGET_PATH", "artifacts")
run_dbt(["run"], expect_pass=False)

write_file(models__second_model, "models", "sample_model.sql")

results = run_dbt(["retry"])
assert len(results) == 1


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

def test_retry_target_path_flag(self, project):
run_dbt(["run", "--target-path", "target"], expect_pass=False)

project_root = project.project_root
move(project_root / "target", project_root / "artifacts")

write_file(models__second_model, "models", "sample_model.sql")

results = run_dbt(["retry", "--state", "artifacts", "--target-path", "my_target_path"])
assert len(results) == 1
assert Path("my_target_path").is_dir()

0 comments on commit d1e400e

Please sign in to comment.