Skip to content

Commit

Permalink
Updates lib to use new profile name functionality (#6202) (#6221)
Browse files Browse the repository at this point in the history
* Updates lib to use new profile name functionality

* Adds changie entry

* Fixes formatting

(cherry picked from commit d0543c9)

Co-authored-by: Rachel <41338402+racheldaniel@users.noreply.github.com>
Co-authored-by: leahwicz <60146280+leahwicz@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 16, 2022
1 parent 9026a05 commit 54d1865
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changes/unreleased/Features-20221102-150003.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
kind: Features
body: This pulls the profile name from args when constructing a RuntimeConfig in lib.py,
enabling the dbt-server to override the value that's in the dbt_project.yml
time: 2022-11-02T15:00:03.000805-05:00
custom:
Author: racheldaniel
Issue: "6201"
PR: "6202"
14 changes: 11 additions & 3 deletions core/dbt/lib.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import os
from dbt.config.project import Project
from dbt.config.renderer import DbtProjectYamlRenderer
from dbt.contracts.results import RunningStatus, collect_timing_info
from dbt.events.functions import fire_event
from dbt.events.types import NodeCompiling, NodeExecuting
Expand Down Expand Up @@ -71,16 +73,22 @@ def get_dbt_config(project_dir, args=None, single_threaded=False):
else:
profiles_dir = flags.DEFAULT_PROFILES_DIR

profile_name = getattr(args, "profile", None)

runtime_args = RuntimeArgs(
project_dir=project_dir,
profiles_dir=profiles_dir,
single_threaded=single_threaded,
profile=getattr(args, "profile", None),
profile=profile_name,
target=getattr(args, "target", None),
)

# Construct a RuntimeConfig from phony args
config = RuntimeConfig.from_args(runtime_args)
profile = RuntimeConfig.collect_profile(args=runtime_args, profile_name=profile_name)
project_renderer = DbtProjectYamlRenderer(profile, None)
project = RuntimeConfig.collect_project(args=runtime_args, project_renderer=project_renderer)
assert type(project) is Project

config = RuntimeConfig.from_parts(project, profile, runtime_args)

# Set global flags from arguments
flags.set_from_args(args, config)
Expand Down

0 comments on commit 54d1865

Please sign in to comment.