def profile_from_dict(profile, profile_name, cli_vars='{}'): from dbt.config import Profile, ConfigRenderer from dbt.context.base import generate_base_context from dbt.utils import parse_cli_vars if not isinstance(cli_vars, dict): cli_vars = parse_cli_vars(cli_vars) renderer = ConfigRenderer(generate_base_context(cli_vars)) return Profile.from_raw_profile_info( profile, profile_name, renderer, )
def config_from_parts_or_dicts(project, profile, packages=None, cli_vars='{}'): from dbt.config import Project, Profile, RuntimeConfig from dbt.utils import parse_cli_vars from copy import deepcopy if not isinstance(project, Project): project = Project.from_project_config(deepcopy(project), packages) if not isinstance(profile, Profile): profile = Profile.from_raw_profile_info(deepcopy(profile), project.profile_name) if not isinstance(cli_vars, dict): cli_vars = parse_cli_vars(cli_vars) return RuntimeConfig.from_parts(project=project, profile=profile, cli_vars=cli_vars)
def config_from_parts_or_dicts(project, profile, packages=None, cli_vars='{}'): from dbt.config import Project, Profile, RuntimeConfig from dbt.utils import parse_cli_vars from copy import deepcopy if not isinstance(cli_vars, dict): cli_vars = parse_cli_vars(cli_vars) if not isinstance(project, Project): project = Project.from_project_config(deepcopy(project), packages) if not isinstance(profile, Profile): profile = Profile.from_raw_profile_info(deepcopy(profile), project.profile_name, cli_vars) args = Obj() args.vars = repr(cli_vars) return RuntimeConfig.from_parts( project=project, profile=profile, args=args )
def validate_connection(cls, target_dict): """Validate a connection dictionary. On error, raises a DbtConfigError. """ target_name = 'test' # make a fake profile that we can parse profile_data = { 'outputs': { target_name: target_dict, }, } # this will raise a DbtConfigError on failure profile = Profile.from_raw_profile_info( raw_profile=profile_data, profile_name='', target_override=target_name, renderer=ProfileRenderer(generate_base_context({})), ) result = cls.attempt_connection(profile) if result is not None: raise dbt.exceptions.DbtProfileError( result, result_type='connection_failure')