Skip to content

Commit 06c7a8a

Browse files
emmyoopdbeatty10
andauthored
Allow missing profiles.yml for dbt deps and dbt init (#7546) (#7677)
* 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` Co-authored-by: Doug Beatty <[email protected]>
1 parent 19e2f2e commit 06c7a8a

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: Fixes
2+
body: Allow missing `profiles.yml` for `dbt deps` and `dbt init`
3+
time: 2023-05-08T07:29:29.873793-06:00
4+
custom:
5+
Author: dbeatty10
6+
Issue: "7511"

core/dbt/cli/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def debug(ctx, **kwargs):
421421
@cli.command("deps")
422422
@click.pass_context
423423
@p.profile
424-
@p.profiles_dir
424+
@p.profiles_dir_exists_false
425425
@p.project_dir
426426
@p.target
427427
@p.vars
@@ -443,7 +443,7 @@ def deps(ctx, **kwargs):
443443
# for backwards compatibility, accept 'project_name' as an optional positional argument
444444
@click.argument("project_name", required=False)
445445
@p.profile
446-
@p.profiles_dir
446+
@p.profiles_dir_exists_false
447447
@p.project_dir
448448
@p.skip_profile_setup
449449
@p.target

core/dbt/cli/params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@
293293
)
294294

295295
# `dbt debug` uses this because it implements custom behaviour for non-existent profiles.yml directories
296+
# `dbt deps` does not load a profile at all
297+
# `dbt init` will write profiles.yml if it doesn't yet exist
296298
profiles_dir_exists_false = click.option(
297299
"--profiles-dir",
298300
envvar="DBT_PROFILES_DIR",

tests/functional/profiles/test_profile_dir.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import dbt.flags as flags
1010

1111
from dbt.tests.util import (
12+
run_dbt,
1213
run_dbt_and_capture,
1314
write_file,
1415
rm_file,
@@ -89,6 +90,15 @@ def environ(env):
8990
os.environ[key] = value
9091

9192

93+
class TestProfilesMayNotExist:
94+
def test_debug(self, project):
95+
# The database will not be able to connect; expect neither a pass or a failure (but not an exception)
96+
run_dbt(["debug", "--profiles-dir", "does_not_exist"], expect_pass=None)
97+
98+
def test_deps(self, project):
99+
run_dbt(["deps", "--profiles-dir", "does_not_exist"])
100+
101+
92102
class TestProfiles:
93103
def dbt_debug(self, project_dir_cli_arg=None, profiles_dir_cli_arg=None):
94104
# begin with no command-line args or user config (from profiles.yml)

0 commit comments

Comments
 (0)