Skip to content

Commit

Permalink
Remove --dry-run flag from dbt deps (#9169)
Browse files Browse the repository at this point in the history
* Rm --dry-run flag for dbt deps

* Add changelog entry

* Update test

* PR feedback
  • Loading branch information
jtcohen6 authored Dec 11, 2023
1 parent 1740df5 commit 6e0a387
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 18 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Breaking Changes-20231129-091921.yaml
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 0 additions & 7 deletions core/dbt/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ def debug(ctx, **kwargs):
@p.target
@p.vars
@p.source
@p.dry_run
@p.lock
@p.upgrade
@p.add_package
Expand All @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions core/dbt/cli/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 3 additions & 2 deletions core/dbt/task/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/dependencies/test_dependency_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ 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(
[
"deps",
"--add-package",
"dbt-labs/[email protected]",
"--dry-run",
"--lock",
]
)
assert not os.path.exists("dbt_packages")
Expand Down

0 comments on commit 6e0a387

Please sign in to comment.