From 75c95cc951d6b1098de599ba3e017548585649e1 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Wed, 29 Nov 2023 09:09:31 +0100 Subject: [PATCH 1/4] Rm --dry-run flag for dbt deps --- core/dbt/cli/main.py | 7 ------- core/dbt/cli/params.py | 7 ------- core/dbt/task/deps.py | 5 +++-- tests/functional/dependencies/test_dependency_options.py | 1 - 4 files changed, 3 insertions(+), 17 deletions(-) diff --git a/core/dbt/cli/main.py b/core/dbt/cli/main.py index 2454a15a564..61ff8d03773 100644 --- a/core/dbt/cli/main.py +++ b/core/dbt/cli/main.py @@ -457,7 +457,6 @@ def debug(ctx, **kwargs): @p.target @p.vars @p.source -@p.dry_run @p.lock @p.upgrade @p.add_package @@ -483,12 +482,6 @@ def deps(ctx, **kwargs): message=f"Version is required in --add-package when a package when source is {flags.SOURCE}", option_name="--add-package", ) - else: - if flags.DRY_RUN: - raise BadOptionUsage( - message="Invalid flag `--dry-run` when not using `--add-package`.", - option_name="--dry-run", - ) task = DepsTask(flags, ctx.obj["project"]) results = task.run() success = task.interpret_results(results) diff --git a/core/dbt/cli/params.py b/core/dbt/cli/params.py index 907f485f3b3..3e03376f890 100644 --- a/core/dbt/cli/params.py +++ b/core/dbt/cli/params.py @@ -83,13 +83,6 @@ hidden=True, ) -dry_run = click.option( - "--dry-run", - envvar=None, - help="Option to run `dbt deps --add-package` without updating package-lock.yml file.", - is_flag=True, -) - empty = click.option( "--empty/--no-empty", envvar="DBT_EMPTY", diff --git a/core/dbt/task/deps.py b/core/dbt/task/deps.py index a694f78dac5..54ec0db4e1f 100644 --- a/core/dbt/task/deps.py +++ b/core/dbt/task/deps.py @@ -220,8 +220,9 @@ def run(self) -> None: if previous_hash != current_hash: self.lock() - # Early return when dry run or lock only. - if self.args.dry_run or self.args.lock: + # Early return when 'dbt deps --lock' + # Just resolve packages and write lock file, don't actually install packages + if self.args.lock: return if system.path_exists(self.project.packages_install_path): diff --git a/tests/functional/dependencies/test_dependency_options.py b/tests/functional/dependencies/test_dependency_options.py index 5ddc243bf37..7d068c42bc3 100644 --- a/tests/functional/dependencies/test_dependency_options.py +++ b/tests/functional/dependencies/test_dependency_options.py @@ -82,7 +82,6 @@ def test_deps_add_dry_run(self, clean_start): "deps", "--add-package", "dbt-labs/audit_helper@0.9.0", - "--dry-run", ] ) assert not os.path.exists("dbt_packages") From e70b070604b556ac9442b3a3ba30c162678a9b74 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Wed, 29 Nov 2023 09:19:26 +0100 Subject: [PATCH 2/4] Add changelog entry --- .changes/unreleased/Breaking Changes-20231129-091921.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/unreleased/Breaking Changes-20231129-091921.yaml diff --git a/.changes/unreleased/Breaking Changes-20231129-091921.yaml b/.changes/unreleased/Breaking Changes-20231129-091921.yaml new file mode 100644 index 00000000000..c58c598a46e --- /dev/null +++ b/.changes/unreleased/Breaking Changes-20231129-091921.yaml @@ -0,0 +1,7 @@ +kind: Breaking Changes +body: Rm --dry-run flag from 'dbt deps --add-package', in favor of just 'dbt deps + --lock' +time: 2023-11-29T09:19:21.071212+01:00 +custom: + Author: jtcohen6 + Issue: "9100" From 1e3d3dcceafc894082cf8ac3a28342db0c0f1f79 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Wed, 29 Nov 2023 11:35:55 +0100 Subject: [PATCH 3/4] Update test --- tests/functional/dependencies/test_dependency_options.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/functional/dependencies/test_dependency_options.py b/tests/functional/dependencies/test_dependency_options.py index 7d068c42bc3..cdc89a45560 100644 --- a/tests/functional/dependencies/test_dependency_options.py +++ b/tests/functional/dependencies/test_dependency_options.py @@ -82,6 +82,7 @@ def test_deps_add_dry_run(self, clean_start): "deps", "--add-package", "dbt-labs/audit_helper@0.9.0", + "--lock", ] ) assert not os.path.exists("dbt_packages") From fc6538d6220859cd7161b95b603e25a9da2902c5 Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Mon, 11 Dec 2023 17:21:16 +0100 Subject: [PATCH 4/4] PR feedback --- tests/functional/dependencies/test_dependency_options.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/dependencies/test_dependency_options.py b/tests/functional/dependencies/test_dependency_options.py index cdc89a45560..a6a200bf3d5 100644 --- a/tests/functional/dependencies/test_dependency_options.py +++ b/tests/functional/dependencies/test_dependency_options.py @@ -75,7 +75,7 @@ def test_deps_add(self, clean_start): ) assert len(os.listdir("dbt_packages")) == 3 - def test_deps_add_dry_run(self, clean_start): + def test_deps_add_without_install(self, clean_start): os.rename("packages.yml", "dependencies.yml") run_dbt( [