Skip to content

Commit

Permalink
Allow missing profiles.yml for dbt deps and dbt init (#7546)
Browse files Browse the repository at this point in the history
* Allow missing `profiles.yml` for `dbt deps` and `dbt init`

* Some commands allow the `--profiles-dir` to not exist

* Remove fix to verify that CI tests work

* Allow missing `profiles.yml` for `dbt deps` and `dbt init`

* CI is not finding any installed adapters

* Remove functional test for `dbt init`
  • Loading branch information
dbeatty10 authored May 11, 2023
1 parent 05595f5 commit 630cd3a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Fixes-20230508-072929.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Fixes
body: Allow missing `profiles.yml` for `dbt deps` and `dbt init`
time: 2023-05-08T07:29:29.873793-06:00
custom:
Author: dbeatty10
Issue: "7511"
4 changes: 2 additions & 2 deletions core/dbt/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def debug(ctx, **kwargs):
@cli.command("deps")
@click.pass_context
@p.profile
@p.profiles_dir
@p.profiles_dir_exists_false
@p.project_dir
@p.target
@p.vars
Expand All @@ -444,7 +444,7 @@ def deps(ctx, **kwargs):
# for backwards compatibility, accept 'project_name' as an optional positional argument
@click.argument("project_name", required=False)
@p.profile
@p.profiles_dir
@p.profiles_dir_exists_false
@p.project_dir
@p.skip_profile_setup
@p.target
Expand Down
2 changes: 2 additions & 0 deletions core/dbt/cli/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@
)

# `dbt debug` uses this because it implements custom behaviour for non-existent profiles.yml directories
# `dbt deps` does not load a profile at all
# `dbt init` will write profiles.yml if it doesn't yet exist
profiles_dir_exists_false = click.option(
"--profiles-dir",
envvar="DBT_PROFILES_DIR",
Expand Down
10 changes: 10 additions & 0 deletions tests/functional/profiles/test_profile_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import dbt.flags as flags

from dbt.tests.util import (
run_dbt,
run_dbt_and_capture,
write_file,
rm_file,
Expand Down Expand Up @@ -89,6 +90,15 @@ def environ(env):
os.environ[key] = value


class TestProfilesMayNotExist:
def test_debug(self, project):
# The database will not be able to connect; expect neither a pass or a failure (but not an exception)
run_dbt(["debug", "--profiles-dir", "does_not_exist"], expect_pass=None)

def test_deps(self, project):
run_dbt(["deps", "--profiles-dir", "does_not_exist"])


class TestProfiles:
def dbt_debug(self, project_dir_cli_arg=None, profiles_dir_cli_arg=None):
# begin with no command-line args or user config (from profiles.yml)
Expand Down

0 comments on commit 630cd3a

Please sign in to comment.