11import json
2- import sys
32from typing import Any , Dict
43
54import click
65
76from data_pipelines_cli .dbt_cloud_api_client import DbtCloudApiClient
87from ..cli_constants import BUILD_DIR
98from ..cli_utils import echo_info
10- from ..config_generation import read_dictionary_from_config_directory , generate_profiles_yml
11- from ..dbt_utils import _dump_dbt_vars_from_configs_to_string , run_dbt_command
9+ from ..config_generation import read_dictionary_from_config_directory
10+ from ..dbt_utils import _dump_dbt_vars_from_configs_to_string
1211
1312
1413def read_dbtcloud_config () -> Dict [str , Any ]:
@@ -35,26 +34,6 @@ def read_bigquery_config(env: str) -> Dict[str, Any]:
3534 return read_dictionary_from_config_directory (BUILD_DIR .joinpath ("dag" ), env , "bigquery.yml" )
3635
3736
38- def resolve_env_var (unresolved_text , env ):
39- """
40- Resolves environment variables and jinja in the given text using the dbt show command.
41- :param unresolved_text: Text to be resolved
42- :param env: Environment dir name
43- :return: Parsed text
44- """
45- profiles_path = generate_profiles_yml (env , False )
46- dbt_command_result_bytes = run_dbt_command (
47- ("show" , "--inline" , f"SELECT '{ unresolved_text } ' AS parsed" , "--output" , "json" ),
48- env ,
49- profiles_path ,
50- log_format_json = True ,
51- capture_output = True )
52- decoded_output = dbt_command_result_bytes .stdout .decode (encoding = sys .stdout .encoding or "utf-8" )
53- for line in map (json .loads , decoded_output .splitlines ()):
54- if line .get ('data' , {}).get ('node_name' ) == "inline_query" :
55- return json .loads (line ["data" ]["preview" ])[0 ]["parsed" ]
56-
57-
5837@click .command (name = "configure-cloud" , help = "Create dbt Cloud project" )
5938@click .option (
6039 "--account_id" ,
@@ -106,8 +85,7 @@ def configure_cloud_command(
10685 environments_projects = {}
10786 for environment in dbtcloud_config ["environments" ]:
10887 bq_config = read_bigquery_config (environment ["config_dir" ])
109- environments_projects [environment ["name" ]] = resolve_env_var (bq_config ["project" ],
110- environment ["config_dir" ])
88+ environments_projects [environment ["name" ]] = bq_config ["project" ]
11189 environment_id = create_environment (client , environment , bq_config ["dataset" ],
11290 dbtcloud_project_id )
11391 if environment ["type" ] == "deployment" :
0 commit comments