Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport] Allow missing profiles.yml for dbt deps and dbt init #7677

Merged
merged 1 commit into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -421,7 +421,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 @@ -443,7 +443,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