From d6b514756673449442b2116681933f76157e44e6 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 15 Nov 2022 22:09:55 -0500 Subject: [PATCH] Updates lib to use new profile name functionality (#6202) (#6220) * Updates lib to use new profile name functionality * Adds changie entry * Fixes formatting (cherry picked from commit d0543c92426b8d95e4a3e7c79a5050c8a6e322bd) Co-authored-by: Rachel <41338402+racheldaniel@users.noreply.github.com> Co-authored-by: leahwicz <60146280+leahwicz@users.noreply.github.com> --- .changes/unreleased/Features-20221102-150003.yaml | 8 ++++++++ core/dbt/lib.py | 14 +++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 .changes/unreleased/Features-20221102-150003.yaml diff --git a/.changes/unreleased/Features-20221102-150003.yaml b/.changes/unreleased/Features-20221102-150003.yaml new file mode 100644 index 00000000000..ca45893dfe9 --- /dev/null +++ b/.changes/unreleased/Features-20221102-150003.yaml @@ -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" diff --git a/core/dbt/lib.py b/core/dbt/lib.py index 1385dd889b3..ebbc3e73d9d 100644 --- a/core/dbt/lib.py +++ b/core/dbt/lib.py @@ -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 @@ -71,16 +73,22 @@ def get_dbt_config(project_dir, args=None, single_threaded=False): else: profiles_dir = os.path.expanduser("~/.dbt") + 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)